Skip to content

Instantly share code, notes, and snippets.

Applied Functional Programming with Scala - Notes

Copyright © 2016-2018 Fantasyland Institute of Learning. All rights reserved.

1. Mastering Functions

A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.

val square : Int => Int = x => x * x
@codeck
codeck / it.scala
Last active January 2, 2016 13:38 — forked from Centaur/it.scala
val arg1 = Iterator(2, 3, 4, 8, 9, 12, 14, 17)
val arg2 = Iterator(1, 2, 3, 4, 6, 8, 9, 10, 11, 12, 13, 14, 17)
//??(arg1, arg2)=> Iterator((2, 4), (8, 9), (12, 12),(14, 17))
case class CeRange(start:Int, end:Option[Int]) {
def passed(br: Int) = {
end.map(br < _).getOrElse(true)
}
}