
Stream
s. Their laziness allows really nice implementations of incremental algorithms and tail-recursive functions. the best thing is they can be used efficiently under different requirements: no matter if you are interested in each intermediate result or only the final one, you'll only need one implementations. =)I hope the following example computing the factorial(s) using Streams explains it well:
No comments:
Post a Comment