Sunday, 25 December 2011

Lazy prime numbers in Scala


The key to understanding this example is the #:: operator. It is very similar to :: for collections. The difference is that it doesn't evaluate the right hand side argument immediately. Instead it keeps it's reference as a function and evaluates it only when needed. The evaluation is deferred until the actual element is needed.

No comments:

Post a Comment