Last active
July 18, 2019 06:45
-
-
Save beizhedenglong/8b22f42415f6c35fa7b77a3f62b55055 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| const streamMaker = (f) => { | |
| const aux = x => [f(x), () => aux(x + 1)] | |
| return () => aux(0) | |
| } | |
| const ones2 = streamMaker(x => x + 100) | |
| const numberUntil = (s, predict) => { | |
| const aux = (s, ans) => { | |
| const [result, th] = s() | |
| if (predict(result)) { | |
| return ans | |
| } | |
| return aux(th, ans + 1) | |
| } | |
| return aux(s, 1) | |
| } | |
| console.log(numberUntil(ones2, x => x === 200)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment