Skip to content

Instantly share code, notes, and snippets.

@Pitometsu
Created April 18, 2022 11:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pitometsu/3898f5aeedd787a2ff2efdb82333f922 to your computer and use it in GitHub Desktop.
Save Pitometsu/3898f5aeedd787a2ff2efdb82333f922 to your computer and use it in GitHub Desktop.
partial application
Yan Shkurinskiy, [18/4/22 8:41 AM]
foo :: Int -> Int
foo x = map fib [0..] !! x
where
fib 0 = 1
fib 1 = 1
fib n = foo (n-2) + foo (n-1)
foo :: Int -> Int
foo = (map fib [0..] !!)
where
fib 0 = 1
fib 1 = 1
fib n = foo (n-2) + foo (n-1)
первый выполняется долго, второй - быстро
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment