streamjs和linqjs有什么关系 [英] What's the relationship between streamjs and linqjs
问题描述
阅读SICP之后,我最近发现了 streamjs .开发人员引用 linqjs 作为具有不同语法的替代实现,但是我无法建立连接. streamjs中的方法如何映射到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?
推荐答案
我都没有使用任何一个库,但是,这是我的初步分析(我已经阅读了很多SICP,但请注意,并不是全部内容).
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
是列表的功能样式数据结构的实现.功能语言中的许多数据结构倾向于递归,就像Stream
结构一样.它由头元素和尾部的Stream
(后续元素)组成.在这里,可以通过允许尾部成为函数(即无限序列)来实现惰性评估.
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).
现在,要回答您的问题,linq.js
提供的所有功能都应该能够与其他常见的高阶功能(例如,地图,缩小,行走,折叠等)一起定义.
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.
当然,stream.js
不会实现linq.js
中的Any()
方法,但是您可以使用reduce()
来实现.
Sure, stream.js
does not implement the Any()
method from linq.js
, but you can just do that with reduce()
.
这篇关于streamjs和linqjs有什么关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!