CamolaZ

fib

Apr 2nd, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. fib :: Int -> Integer
  2. fib 0 = 0
  3. fib 1 = 1
  4. fib n = fib (n-1) + fib (n-2)
  5.  
  6. fib' :: Int -> Integer
  7. fib' n = fst $ sequence !! n -- backslash is similar so stay as lambda function, first element of pair
  8.  where --to !! marks for index
  9.  --relation to , image  of function
Add Comment
Please, Sign In to add comment