Created
July 2, 2014 08:14
-
-
Save soc/49abe9a21efde8b394b4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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