new tasks
This commit is contained in:
parent
2a4d27cea0
commit
80737d5a6a
1194 changed files with 15353 additions and 1 deletions
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