diff options
author | Braxton Hall | 2022-10-23 21:40:30 +0000 |
---|---|---|
committer | GitHub | 2022-10-23 21:40:30 +0000 |
commit | a0fab0d8ac452063375d4bba76466803c28258f0 (patch) | |
tree | 6bb0e219d757c4b01f374411758d4720766da52f /entries/jyoo980/scala | |
parent | 3de00aa8511713c50564fa183671486530fdc0ae (diff) | |
parent | 9d6f7b9b5123c6e6d8d5a13ee3f4b5f63a0cf663 (diff) |
Merge pull request #2 from jyoo980/main
Adding fib in Scala
Diffstat (limited to 'entries/jyoo980/scala')
-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..f9107b0 --- /dev/null +++ b/entries/jyoo980/scala/Fib.scala @@ -0,0 +1,6 @@ +def fib(n: Int): Int = + (0 until n).foldLeft((0, 1)) { + case ((prev, curr), _) => (curr, prev + curr) + } match { + case (n, _) => n + } |