Skip to content

Instantly share code, notes, and snippets.

@robertjlooby
Created August 19, 2015 13:46
Show Gist options
  • Save robertjlooby/1950525cb9a4745ecc2d to your computer and use it in GitHub Desktop.
Save robertjlooby/1950525cb9a4745ecc2d to your computer and use it in GitHub Desktop.
elm-fibonacci
module Fibonacci where
import List exposing (reverse, sum, take)
import Graphics.Element exposing (show)
fibonacci : Int -> List Int
fibonacci n =
let fibonacci' n acc =
if n <= 2 then
acc
else
fibonacci' (n-1) ((take 2 >> sum) acc :: acc)
in
fibonacci' n [1,1] |> reverse
main = show <| fibonacci 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment