ストリームの値の移り変わり
/** * Created by devel on 2017/04/01. */ var expect = require('expect.js'); var succ = (n)=>{ return n + 1 } var enumFrom =(n)=>{ return [n, (_)=>{ return enumFrom(succ(n)) }] } a = enumFrom(1) // nに1を代入 console.log(a) // [ 1, [Function] ] console.log(a[0]) // 1 console.log('') console.log(a[1]()) // [ 2, [Function] ] console.log(a[1]()[0]) // 2 console.log('') console.log(a[1]()[1]()) // [ 3, [Function] ] console.log(a[1]()[1]()[0]) // 3 console.log('') console.log(a[1]()[1]()[1]()) // [ 4, [Function] ] console.log(a[1]()[1]()[1]()[0]) // 4