Created
March 28, 2013 21:20
-
-
Save dacr/5266909 to your computer and use it in GitHub Desktop.
Append a stream A to a stream B doesn't imply evaluation of all items of the first Stream A.
This file contains 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
#!/bin/sh | |
exec scala -deprecation -nocompdaemon "$0" "$@" | |
!# | |
def trace(x:Int) = {println(x); x} | |
val x=(1 to 5).toStream.map(trace _) | |
// 1 is printed | |
val y=(5 to 1 by -1).toStream.map(trace _) | |
// 5 is printed | |
val z=x++y | |
// nothing is printed | |
println("NOW let's materialize the stream") | |
z.toList | |
// 2 3 4 5 4 3 2 1 is printed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment