Advertisement
Guest User

Untitled

a guest
Aug 21st, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. import "prelude.eg"
  2.  
  3. using System
  4. using List
  5.  
  6. data open, closed
  7.  
  8. def toggle =
  9. [ open N -> closed N | closed N -> open N ]
  10.  
  11. def doors =
  12. [ N -> map [ N -> closed N ] (fromto 1 N) ]
  13.  
  14. def toggleK =
  15. [ K, nil -> nil
  16. | K, cons (D N) DD ->
  17. let DOOR = if (N%K) == 0 then toggle (D N) else D N in
  18. cons DOOR (toggleK K DD) ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement