minor improvements
This commit is contained in:
parent
e58c399bad
commit
34b1ff39ce
@ -3,7 +3,7 @@ def intsFrom(n: Int): LazyList[Int] = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def primeNumbers(list: LazyList[Int]): LazyList[Int] = {
|
def primeNumbers(list: LazyList[Int]): LazyList[Int] = {
|
||||||
list.head #:: primeNumbers(list.filter(n => n % list.head != 0))
|
list.head #:: primeNumbers(list.tail.filter(n => n % list.head != 0))
|
||||||
}
|
}
|
||||||
val ints: LazyList[Int] = intsFrom(2)
|
val ints: LazyList[Int] = intsFrom(2)
|
||||||
primeNumbers(ints).take(10).toList
|
primeNumbers(ints).take(10).toList
|
@ -3,9 +3,9 @@ def addStream(s1: LazyList[Int], s2: LazyList[Int]): LazyList[Int] = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def fibonacci(): LazyList[Int] = {
|
def fibonacci(): LazyList[Int] = {
|
||||||
0 #:: addStream(
|
0 #:: 1 #:: addStream(
|
||||||
1 #:: fibonacci(),
|
fibonacci(),
|
||||||
fibonacci()
|
fibonacci().tail
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user