Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- zero = \f -> \x -> x
- mySucc = \n -> \f -> \x -> f $ n f x
- add = \n -> \m -> n mySucc m
- mkPair = \a -> \b -> \s -> s a b
- myFst = \a -> \b -> a
- mySnd = \a -> \b -> b
- step = \p -> mkPair (p mySnd) (mySucc (p mySnd))
- nSteps = \n -> \p -> n step p
- zz = mkPair zero zero
- myPred = \n -> (nSteps n zz) myFst
- one = mySucc zero
- two = mySucc (mySucc zero)
- three = mySucc (mySucc (mySucc zero))
- six = add (add two three) one
- main :: IO ()
- main = do
- let p = mkPair two three
- let n = nSteps three p
- putStrLn $ show $ (myPred six) (\x -> x + 1) 0 -- => 5
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement