Hoon101 Week 2 Assignment in "Haskell"
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
Thorn Avery 5a157d66b0 first commit pirms 4 gadiem
README.md first commit pirms 4 gadiem
week2.hs first commit pirms 4 gadiem

README.md

I'm so sorry

Hoon101's Week 2 Assignment in Haskell

Create a gate that takes a noun, checks if its a cell, and if not, checks if the atom is odd or even

Running

in ghci, load the file:

:load week2.hs

you can then run the program using the form

:t solution (nil :: X)

where X is either an atom or a cell, using the following syntax:

Atom: Using Church Encoding with (S n) and Z, ie (S (S (S Z))) is the atom 3

Cell: Using Cons x xs and Nil, ie (Cons (S Z) (Cons Z Z)) is the cell [1 [0 0]]

Example

*Main> :load week2.hs 
[1 of 1] Compiling Main             ( week2.hs, interpreted )
Ok, modules loaded: Main.

*Main> :t solution (nil :: (S (S (S (S Z)))))
solution (nil :: (S (S (S (S Z)))))
   :: IsEvenAtom

*Main> :t solution (nil :: (S (S (S (S (S Z))))))
solution (nil :: (S (S (S (S (S Z))))))
   :: IsOddAtom

*Main> :t solution (nil :: (Cons (Cons (S Z) (S (S Z))) (Cons (S (S (S Z))) (S (S (S (S Z)))))))
solution (nil :: (Cons (Cons (S Z) (S (S Z))) (Cons (S (S (S Z))) (S (S (S (S Z)))))))
   :: IsCell