Hoon101 Week 2 Assignment in "Haskell"
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
Thorn Avery 5a157d66b0 first commit 4 年前
README.md first commit 4 年前
week2.hs first commit 4 年前

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