File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed
Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments