Using a Stream to Generate a Random Sequence
genRandom creates a stream of random numbers that has a one in four chance of terminating each time it's called.
Note the #:: construct, which lazily recurses: because it is prepending the current random number to a stream, it does not evaluate the remainder of the stream until it is iterated through.
Infinite Streams via Recursion
Streams can be built that reference themselves and thus become infinitely recursive.
In this context the difference between Var, Val, and Def is interesting. As a def each element is recalculated every time it is referenced. As a val each element is retained and reused after it's been calculated. This can be demonstrated by creating a side-effect with each calculation.
This also explains why the random number Stream doesn't work as a val.