Last active
May 15, 2018 08:39
-
-
Save jesty/c557a481a1a566239766ee2880a51f24 to your computer and use it in GitHub Desktop.
Fibonacci in Scala
This file contains 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
def seriesUntilPosition(n: Int) = (0 until n) | |
.map(x => (0,0)) | |
.foldLeft((0,1))((acc, b) => (acc._2, acc._1 + acc._2))._2 | |
def seriesUntil(n: Int) = (0 to n).map(fibo(_)) ( |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment