Advertisement
Guest User

silmal hoon school 101 week 3 part 2

a guest
Dec 10th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. :: Define a naked gate that takes a list of atoms.
  2. :: I used * because I couldn't figure out what was the 'type' of a list.
  3. ::
  4. |= n=*
  5. :: Initialize i with value 1.
  6. ::
  7. =/ i=@ud 1
  8. :: Set a recursion point to loop over the list elements.
  9. ::
  10. |-
  11. :: Check if i == 3; if so, return the head of our list.
  12. ::
  13. ?: =(i 3)
  14. -:n
  15. :: Otherwise, recur with the tail of our list after incrementing i.
  16. ::
  17. $(n +:n, i (add 1 i))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement