Advertisement
xastor

hoon 101 week 2

Jul 21st, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. :: Assignment:
  2. ::
  3. :: Build a naked generator that takes a noun and checks if that noun is a cell or an atom.
  4. :: If that input noun is an atom, check if it’s even or odd.
  5. :: The output should be of the tape type. A tape is a string.
  6. ::
  7. |= a=* :: gate
  8. ?: ?= @ a :: a is an atom?
  9. ?: .= 0 (mod a 2) :: a is even?
  10. 'even' :: even!
  11. 'odd' :: odd!
  12. 'not an atom' :: not an atom
  13. ::
  14. :: or in one line :
  15. :: ?@(a ?:(=((mod a 2) 0) 'even' 'odd') 'not an atom')
  16. ::
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement