Paul Sweatte Paul Sweatte - 7 months ago 21
Javascript Question

What's the relationship between streamjs and linqjs

After reading SICP, I recently discovered streamjs. The developer referenced linqjs as an alternate implementation with different syntax, but I can't make the connection. How do the methods in streamjs map to those in linqjs?


I haven't used either library, but, here's my initial analysis (I've read quite a bit of SICP, but not the whole thing admittedly).

stream.js is an implementation of a functional style data structure for a list. Many data structures in a functional language tend to be recursive, much like the Stream structure. It is composed of a head element, and a Stream for the tail (subsequent elements). Here, lazy evaluation can be achieved by allowing the tail to be a function (i.e. infinite sequences).

Now, to answer your question, all of the functions provided by linq.js should be able to be defined with other common higher order functions like map, reduce, walk, fold, etc.

Sure, stream.js does not implement the Any() method from linq.js, but you can just do that with reduce().