The Road to Functional Programming

Educational material to learn functional programming in Scala, from scratch, in a structured and comprehensive way.

View project on GitHub

Scala language feature: Lazyness

Overview of definition keywords

Lazy val

lazy val a: Int = {
    println("set!")
    3
}

By-name parameters

def test(value: => Int): Int = {
    if (value > 0) 0 else value * 2
}
test {
    println("test")
    scala.util.Random.nextInt
}

https://stackoverflow.com/questions/4543228/whats-the-difference-between-and-unit

Lazyness is like functions as values

Streams as infinite lists

Simple example of DSL

References