Skip to content

Instantly share code, notes, and snippets.

View klaeufer's full-sized avatar
:octocat:

Konstantin Läufer klaeufer

:octocat:
View GitHub Profile
@klaeufer
klaeufer / KLSigPipeFun.scala
Created September 11, 2022 22:37 — forked from gkthiruvathukal/KLSigPipeFun.scala
Tinkering with Konstantin's example
object KLSigPipeFun {
def main(args: Array[String]) = {
val lines = scala.io.Source.stdin.getLines()
val lineNumbers = Iterator.from(1)
val numberedLines = lineNumbers.zip(lines)
val okLines = numberedLines takeWhile { _ => !scala.sys.process.stdout.checkError() }
val outLines = okLines map { case (number, line) => println(number + ":" + line) }
println(outLines.length + " lines counted")
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Advanced Functional Programming with Scala - Notes

Copyright © 2017 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