Created
August 19, 2015 13:46
-
-
Save robertjlooby/1950525cb9a4745ecc2d to your computer and use it in GitHub Desktop.
elm-fibonacci
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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