Created
May 21, 2021 05:03
-
-
Save nagyadam2092/9eff3fb49dbd59cea873d907a48dcb09 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Id = v => ({v: v,map: f => Id(f(v)) }); | |
var CoFreeF = (a, next) => ({ | |
a: a, | |
next: next, | |
extract: () => a, | |
map: g => CoFreeF(g(a), () => next().map(x=>x.map(g))), | |
}); | |
var f = n => CoFreeF(n + 1, () => Id(f(n + 1))); | |
var stream = f(0); | |
console.log(stream) | |
var x = stream.next().v.next().v.map(x => x * 2).next().v; | |
console.log(x); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment