Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def fib(i: Int, j: Int): Stream[Int] = {
- case 0 | 1 => current
- case _ => Fib( current-1 ) + Fib( current -2 )
- }
- def fib(i: Int, j: Int): Stream[Int] = i #:: fib(j, i + j)
- println(fib(0,1).take(10))
- val fibs: Stream[BigInt] = 0 #:: 1 #:: ( fibs zip fibs.tail map ( n => n._1 + n._2 ) )
- val fibs: Stream[BigInt] = {
- def loop( h:BigInt, n:BigInt ): Stream[BigInt] = h #:: loop( n, h+n )
- loop(0,1)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement