Skip to content

Instantly share code, notes, and snippets.

@mizukmb
Created Jun 9, 2017
Embed
What would you like to do?
fib :: Int -> Int
-- Pattern match
-- fib 0 = 0
-- fib 1 = 1
--
-- fib n = fib (n-1) + fib (n-2)
-- Guard
fib n
| n == 0 = 0
| n == 1 = 1
| otherwise = fib (n-1) + fib (n-2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment