new files
This commit is contained in:
parent
3af7344581
commit
86c034bb8b
1364 changed files with 21352 additions and 0 deletions
3
Task/Ackermann-function/Haskell/ackermann-function-1.hs
Normal file
3
Task/Ackermann-function/Haskell/ackermann-function-1.hs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
ack 0 n = n + 1
|
||||
ack m 0 = ack (m-1) 1
|
||||
ack m n = ack (m-1) (ack m (n-1))
|
||||
9
Task/Ackermann-function/Haskell/ackermann-function-2.hs
Normal file
9
Task/Ackermann-function/Haskell/ackermann-function-2.hs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
-- everything here are [Int] or [[Int]], which would overflow
|
||||
-- * had it not overrun the stack first *
|
||||
ackermann = iterate ack [1..] where
|
||||
ack a = s where
|
||||
s = a!!1 : f (tail a) (zipWith (-) s (1:s))
|
||||
f a (b:bs) = (head aa) : f aa bs where
|
||||
aa = drop b a
|
||||
|
||||
main = mapM_ print $ map (\n -> take (6 - n) $ ackermann !! n) [0..5]
|
||||
Loading…
Add table
Add a link
Reference in a new issue