#scala
#programowanie
https://docs.scala-lang.org/pl/tour/nested-functions.html
Mam pytanie czemu jest tutaj wywoływana funkcja process(xs), na samym końcu metody process?
#programowanie
https://docs.scala-lang.org/pl/tour/nested-functions.html
object FilterTest extends App {
def filter(xs: List[Int], threshold: Int) = {
def process(ys: List[Int]): List[Int] =
if (ys.isEmpty) ys
else if (ys.head < threshold) ys.head :: process(ys.tail)
else process(ys.tail)
process(xs)
}
println(filter(List(1, 9, 2, 8, 3, 7, 4), 5))
}Mam pytanie czemu jest tutaj wywoływana funkcja process(xs), na samym końcu metody process?
- Najlepsze
- Wszystkie komentarze






filtera nieprocess. Po to jest ta metoda definiowana żeby ją wywołać ;PJestescie w stanie wyjasnic jak najlatwiej skrocony zapis +
@cypo: @szwe:
znalazlem... jak cos...