Skip to content

Instantly share code, notes, and snippets.

@soc
Created July 2, 2014 08:14
Show Gist options
  • Select an option

  • Save soc/49abe9a21efde8b394b4 to your computer and use it in GitHub Desktop.

Select an option

Save soc/49abe9a21efde8b394b4 to your computer and use it in GitHub Desktop.
package pspex
import psp.core._
object Main extends App {
def double(x: Int) = {
println(s"1# doubling $x")
x * 2
}
def greaterThanSix(x: Int) = {
println(s"2# filtering $x")
x > 6
}
def halve(x: Int) = {
println(s"3# halving $x")
x / 2
}
val arr: Array[Int] = Array(1, 2, 3, 4, 5, 6).map(double).filter(greaterThanSix).map(halve).take(2)
}
@soc
Copy link
Author

soc commented Jul 2, 2014

1# doubling 1
2# filtering 2
1# doubling 2
2# filtering 4
1# doubling 3
2# filtering 6
1# doubling 4
2# filtering 8
3# halving 8
1# doubling 5
2# filtering 10
3# halving 10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment