16. Example 2
JavaScript
var x = 2, t = 0,
twice = [1], temp = [1];
while(true) {
var v = x * x, t = v;
for(var i = 0; i < twice.length; i++) {
t += twice[i];
}
twice.push(v);
temp.push(t);
if (t > 2000) { break; }
x++;
}
17. Example 2
linq.js
// 1から無限大まで数値をジェネレート [1, 2, 3, 4,...]
var result = Enumerable.ToInfinity(1)
.Select("$*$") // 二乗 [1, 4, 9, 16,...]
.Scan("$+$$") // 和 [1,5,14,30,...]
.First("$>2000"); // 2000を超えた最初の要素
20. RxJS
The Reactive Extensions for JavaScript
(Functional) Reactive Programminng のライブラリ
Microsoftから公式に提供されているライブラリ
C#3.0で導入されたライブラリ
そのJavaScript版
イベントをコレクションとして扱える
The Reactive Extensions (Rx) is a library for composing
asynchronous and event-based programs using observable
sequences and LINQ-style query operators.