Hoon101 Week 2 Assignment in "Haskell"
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 1.1KB

4 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # I'm so sorry
  2. Hoon101's Week 2 Assignment in Haskell
  3. > Create a gate that takes a noun, checks if its a cell, and if not, checks if the atom is odd or even
  4. ## Running
  5. in `ghci`, load the file:
  6. ```
  7. :load week2.hs
  8. ```
  9. you can then run the program using the form
  10. `:t solution (nil :: X)`
  11. where `X` is either an atom or a cell, using the following syntax:
  12. `Atom`: Using Church Encoding with `(S n)` and `Z`, ie `(S (S (S Z)))` is the atom `3`
  13. `Cell`: Using `Cons x xs` and `Nil`, ie `(Cons (S Z) (Cons Z Z))` is the cell `[1 [0 0]]`
  14. ## Example
  15. ```
  16. *Main> :load week2.hs
  17. [1 of 1] Compiling Main ( week2.hs, interpreted )
  18. Ok, modules loaded: Main.
  19. *Main> :t solution (nil :: (S (S (S (S Z)))))
  20. solution (nil :: (S (S (S (S Z)))))
  21. :: IsEvenAtom
  22. *Main> :t solution (nil :: (S (S (S (S (S Z))))))
  23. solution (nil :: (S (S (S (S (S Z))))))
  24. :: IsOddAtom
  25. *Main> :t solution (nil :: (Cons (Cons (S Z) (S (S Z))) (Cons (S (S (S Z))) (S (S (S (S Z)))))))
  26. solution (nil :: (Cons (Cons (S Z) (S (S Z))) (Cons (S (S (S Z))) (S (S (S (S Z)))))))
  27. :: IsCell
  28. ```