Skip to content

Commit 9d8ae38

Browse files
author
Dierk Koenig
committed
minor renamings in Stairs.html
1 parent 82fb833 commit 9d8ae38

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/examples/sequence/Stairs.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,15 @@ <h2>Simple SVG Graphics: Stairs</h2>
6464

6565
const allTrails = Sequence(trail, forever, nextAfter); // pure, lazy
6666
const renderLine = line => svg.innerHTML += line; // impure side effect
67-
const wait = ms => ok => setTimeout( ok, ms); // impure async
68-
const immediate = f => ok => { f(); ok() }; // ready for promise ctor
67+
const waitThenOk = ms => ok => setTimeout(ok, ms); // impure async
68+
const callThenOk = f => ok => { f(); ok() }; // ready for promise ctor
6969

7070
const lazyLines = allTrails
7171
.map( lineFor )
72-
.map( line => () => renderLine(line)) // map to a sequence of _functions_ that can be called as f()
73-
.map( immediate ) // make each function Promise-ready
74-
.and( f => Seq(f, wait(50))) // intersperse with monads FTW
75-
.scan( (acc, cur) => acc.then(() => new Promise(cur)), Promise.resolve(undefined));
72+
.map( line => () => renderLine(line)) // map to a sequence of _functions_ that can be called as f()
73+
.map( callThenOk ) // make each function Promise-ready
74+
.and( f => Seq(f, waitThenOk(50))) // intersperse monadically FTW
75+
.scan( (acc, cur) => acc.then(() => new Promise(cur)), Promise.resolve(undefined)); // fixes sequence
7676

7777
lazyLines
7878
.take(255 * 2) // late "pruning" thanks to laziness

0 commit comments

Comments
 (0)