diff options
author | James Yoo | 2022-10-23 21:31:09 +0000 |
---|---|---|
committer | James Yoo | 2022-10-23 21:31:09 +0000 |
commit | 52035dd7c9c0cca23c4df1a0dc178222bd9beb54 (patch) | |
tree | 892e56f94d8aa7973b6e336be0b6992f323de1af /entries | |
parent | 3de00aa8511713c50564fa183671486530fdc0ae (diff) |
Adding fib in Scala
Diffstat (limited to 'entries')
-rw-r--r-- | entries/jyoo980/scala/Fib.scala | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/entries/jyoo980/scala/Fib.scala b/entries/jyoo980/scala/Fib.scala new file mode 100644 index 0000000..05bdd1e --- /dev/null +++ b/entries/jyoo980/scala/Fib.scala @@ -0,0 +1,6 @@ +def fib(n: Int) = + (0 until n).foldLeft((0, 1)) { + case ((prev, curr), _) => (curr, prev + curr) + } match { + case (n, _) => n + } |