@@ -11,15 +11,15 @@ const LazyBox = g => ({
11
11
// compose with f from outside
12
12
map : f => LazyBox ( _ => f ( g ( ) ) ) ,
13
13
14
- // compose and evaluate
14
+ // compose and evaluate only here!
15
15
fold : f => f ( g ( ) )
16
16
} )
17
17
18
18
19
19
const nextCharForNumberString = str =>
20
20
21
21
// wrap 'str' first into function call
22
- LazyBox ( ( ) => str )
22
+ LazyBox ( _ => str )
23
23
24
24
// every 'map' composes with new function from outside
25
25
// without calling it
@@ -31,45 +31,8 @@ const nextCharForNumberString = str =>
31
31
// compose again and call the function
32
32
. fold ( s => s . toLowerCase ( ) )
33
33
34
- console . log ( nextCharForNumberString ( ' 64 ' ) )
35
-
36
-
37
- // ==== Experiment
38
-
39
- // The bove LazyBox needs a function and ignores its arguments.
40
- // It must be called every time as LazyBox( () => val ),
41
- // which may not be convenient to consume
42
- // It may be more convenient to pass the actual value:
43
-
44
-
45
- // TODO === not finished yet
46
-
47
- const LazyWrapper = x => ( {
48
-
49
- wrapper : ( ) => x ,
50
-
51
- // compose with f from outside
52
- map : f => LazyWrapper ( f ( x ) ) ,
53
-
54
- // compose and evaluate
55
- fold : f => f ( x )
56
- } )
57
-
58
- const nextCharForNumberString1 = str =>
59
-
60
- // wrap 'str' first into function call
61
- LazyWrapper ( str )
62
-
63
- // every 'map' composes with new function from outside
64
- // without calling it
65
- . map ( s => s . trim ( ) )
66
- . map ( r => parseInt ( r ) )
67
- . map ( i => i + 1 )
68
- . map ( i => String . fromCharCode ( i ) )
69
-
70
- // compose again and call the function
71
- . fold ( s => s . toLowerCase ( ) )
72
-
73
- console . log ( nextCharForNumberString1 ( ' 64 ' ) )
74
-
34
+ console . log (
35
+ "nextCharForNumberString(' 64 '): " ,
36
+ nextCharForNumberString ( ' 64 ' )
37
+ )
75
38
0 commit comments