5. Cell / set
仍 仂亞仂 仂弍 仗仂仍仂亢亳 于 仆亠 从舒从仂亠-仍亳弍仂 亰仆舒亠仆亳亠
亳仗仂仍亰亠 仄亠仂亟 set
var a = new C e l l ( ) ;
a . set ( 42 ) ;
..
.
..
.
..
.
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
.
..
.
..
.
..
.
..
.
6. Cell / ctor()
仍亠仆舒亳于舒 - 仗亠亠亟舒 仆舒舒仍仆仂亠 亰仆舒亠仆亳亠 于 从仂仆从仂亠
var a = new C e l l ( 4 2 ) ;
..
.
..
.
..
.
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
.
..
.
..
.
..
.
..
.
7. Cell / unset
仍ミ頴笑 仄仂仄亠仆 仗亠亠仄亠仆仆 仄仂亢仆仂 亟亠仍舒 仗仂亶
var a = new C e l l ( 4 2 ) ;
a . unset ( ) ;
..
.
..
.
..
.
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
.
..
.
..
.
..
.
..
.
8. Cell / unwrap
丕 仗亠亠仄亠仆仆仂亶 仄仂亢仆仂 于亰于舒 仄亠仂亟 unwrap 亟仍 仂亞仂, 仂弍
仗仂仍亳 亰仆舒亠仆亳亠, 从仂仂仂亠 仂仆舒 仂亟亠亢亳
var a = new C e l l ( 4 2 ) ;
c o n s o l e . i n f o ( a . unwrap ( ) ) ;
// > 42
..
.
..
.
..
.
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
.
..
.
..
.
..
.
..
.
9. Cell / unwrap()
仍亳 仗亠亠仄亠仆仆舒 弍仍舒 仗仂亶 - 于仍亠亳 亳从仍ム亠仆亳亠, 仆仂
unwrap 仄仂亢仆仂 仗亠亠亟舒 亰仆舒亠仆亳亠, 从仂仂仂亠 仍亠亟亠 于亠仆,
亠仍亳 仗亠亠仄亠仆仆舒 仗舒
c o n s o l e . i n f o ( new C e l l ( ) . unwrap ( 4 2 ) ) ;
// > 42
..
.
..
.
..
.
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
.
..
.
..
.
..
.
..
.
10. Cell / li
亠于ム亠亶 仗亠亠仄亠仆仆仂亶 仄仂亢仆仂 仗亳仄亠仆亳 仆从亳 亳
仗仂仍亳 亠舒从亳于仆 仗亠亠仄亠仆仆, 从仂仂舒 于磶舒仆舒 仗亠于仂亶
仂亶 仆从亳亠亶: 仗亳 亳亰仄亠仆亠仆亳亳 仗亠于仂亶 - 舒于仂仄舒亳亠从亳
仄亠仆磳 于仂舒
var a = new C e l l ( ) ; // a is unset
var b = a . l i f t ( f u n c t i o n ( a ) {
r e t u r n a+2 ;
} ) ; // b is unset
a . s e t ( 1 ) ; // a contains 1, b contains 3
a . s e t ( 5 ) ; // a contains 1, b contains 7
a . u n s e t ( ) ; // a is unset , b is unset
..
.
..
.
..
.
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
.
..
.
..
.
..
.
..
.
11. Cell / li
仂亢仆仂 从舒亰舒, 仂 亟仍 仄亠仂亟舒 li 于仗仂仍仆磳
仍亠亟ム亳亶 亰舒从仂仆
forall (f ,x) :
new C e l l ( x ) . l i f t ( f ) . unwrap ( ) == f ( x ) ;
..
.
..
.
..
.
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
.
..
.
..
.
..
.
..
.
14. Cell / coalesce
var a = new C e l l ( ) ;
var b = a . c o a l e s c e ( 4 2 ) ; // b contains 42
a . s e t ( 1 3 ) ; // a contains 13, b contains 13
a . u n s e t ( ) ; // a is unset , b contains 42
..
.
..
.
..
.
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
.
..
.
..
.
..
.
..
.
15. Cell / isSet
亰仂于 isSet 于亠仆亠 亠舒从亳于仆 仗亠亠仄亠仆仆, 从仂仂舒 仂亟亠亢亳
true 亠仍亳 亳仂亟仆舒 仆亠 仗舒, 亳 false 于 亳仆仂仄 仍舒亠.
var a = new C e l l ( ) ;
var b = a . i s S e t ( ) ; // b has false
a . s e t ( 1 3 ) ; // a has 13, b has true
a . u n s e t ( ) ; // a is unset , b has false
..
.
..
.
..
.
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
.
..
.
..
.
..
.
..
.
17. Cell / when()
var a = new C e l l ( ) ;
var b = a . when ( f u n c t i o n ( a ) {
r e t u r n a >3 ;
} ) ; // b in unset
a . s e t ( 4 2 ) ; // a contains 42, b contains 42
a . s e t ( 4 ) ; // a contains 4, b contains 4
a . s e t ( 1 ) ; // a contains 1, b is unset
..
.
..
.
..
.
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
.
..
.
..
.
..
.
..
.
20. Cell / when(, )
var a = new C e l l ( ) ;
var b = a . when (
f u n c t i o n ( a ) { r e t u r n a >3 ; } ,
f u n c t i o n ( x ) { r e t u r n x+1 }
) ; // b in unset
a . s e t ( 4 2 ) ; // a contains 42, b contains 43
a . s e t ( 4 ) ; // a contains 4, b contains 5
a . s e t ( 1 ) ; // a contains 1, b is unset
..
.
..
.
..
.
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
.
..
.
..
.
..
.
..
.
21. Cell / when(, )
舒 舒仄仂仄 亟亠仍亠 when 亟于仄 舒亞仄亠仆舒仄亳 仗舒从亳亠从亳
从于亳于舒仍亠仆亠仆 从仂仄弍亳仆舒亳亳 when 亳 li
forall (f , t , cell ) :
c e l l . when ( f , t ) == c e l l . when ( f ) . l i f t ( t ) ;
舒从亳亠从亳, 仗仂仂仄 仂, 从舒从 亳 于 仍舒亠 仂亟仆亳仄 仗舒舒仄亠仂仄 于仄亠仂 亳仍舒 亳 舒仆仂仄亠舒 仄仂亢仆仂 仗亠亠亟舒 从仂仆舒仆 亳仍 弍亟亠 舒于仆亳于舒 亰仆舒亠仆亳亠仄 亳仂亟仆仂亶
仗亠亠仄亠仆仆仂亶, 舒 舒仆仂仄亠 于亠仆亠 亠弍
..
.
..
.
..
.
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
.
..
.
..
.
..
.
..
.
22. Cell / when(, )
var a = new C e l l ( ) ;
var b = a . when ( 4 2 , 1 3 ) ; // b in unset
a . s e t ( 4 2 ) ; // a contains 42, b contains 13
a . s e t ( 4 ) ; // a contains 4, b is unset
..
.
..
.
..
.
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
.
..
.
..
.
..
.
..
.
24. Cell / when(, , )
var a = new C e l l ( ) ;
var b = a . when (
f u n c t i o n ( a ) { r e t u r n a >= 0 ; } ,
f u n c t i o n ( x ) { r e t u r n x+1 } ,
f u n c t i o n ( x ) { r e t u r n x1 ; }
) ; // b in unset
a . s e t ( 0 ) ; // a contains 0, b contains 1
a . s e t (1 ) ; // a contains -1, b contains -2
a . u n s e t ( ) ; // a is unset , b in unset
..
.
..
.
..
.
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
.
..
.
..
.
..
.
..
.
25. Cell / when(, , )
仄亠仂 仆从亳亶 仄仂亢仆仂 仗亠亠亟舒 亰仆舒亠仆亳, 于 仂仄 仍舒亠 when
于亠亟亠 亠弍 从舒从 亠舒从亳于仆亶 亠仆舒仆亶 仂仗亠舒仂
var a = new C e l l ( ) ;
var b = a . when ( t r u e , 1 , 0 ) ; // b is unset
a . s e t ( t r u e ) ; // a has true , b has 1
a . s e t ( f a l s e ) ; // a has false , b has 0
a . u n s e t ( ) ; // a is unset , b is unset
..
.
..
.
..
.
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
.
..
.
..
.
..
.
..
.
26. Cell / when(, , )
舒 亳仍ム亠仆亳 仍舒 从仂仆舒仆舒仄亳, 亟仍 when 亠仄
舒亞仄亠仆舒仄亳 于仗仂仍仆磳 亰舒从仂仆
forall (c , f , t ,a) :
c . when ( f , t , a ) == c . l i f t ( f u n c t i o n ( c ) {
return f ( c ) ? t ( c ) : a ( c )
}) ;
..
.
..
.
..
.
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
.
..
.
..
.
..
.
..
.
29. Cell / bind
π経夷歳笑
forall ( cell , f ) :
c e l l . b i n d ( f ) . unwrap ( )
==
f ( c e l l . unwrap ( ) ) . unwrap ( )
弌仍仂亢仆仂 从舒亰舒 亰舒亠仄 亳仄亠仆仆仂 仆亢亠仆 仂 仄仂仆, 舒从 从舒从
仗亳仄亠仆磳 仂仆 仗舒从亳亠从亳 于亠亰亟亠, 仆仂 仆舒仆亠仄 仗仂 仗仂磲从,
从舒亰舒仍, 仂 仆亠亞仂 仗仂仄仂 仄仂亢仆仂 仂亰亟舒 li高
..
.
..
.
..
.
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
.
..
.
..
.
..
.
..
.
30. Cell / bind / li
var c e l l = new C e l l ( ) ;
c e l l . l i f t = function ( f ) {
return t h i s . bind ( function ( x ) {
r e t u r n new C e l l ( f ( x ) ) ;
}) ;
}
..
.
..
.
..
.
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
.
..
.
..
.
..
.
..
.
31. Cell / bind / when
丐亠仗亠 亠舒仍亳亰亠仄 舒仄 仗亠于 仂仄 when
var c e l l = new C e l l ( ) ;
c e l l . when = f u n c t i o n ( f ) {
return t h i s . bind ( function ( x ) {
r e t u r n f ( x ) ? new C e l l ( x ) : new
Cell () ;
}) ;
};
..
.
..
.
..
.
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
.
..
.
..
.
..
.
..
.
33. Cell / bind / binary
var a = new C e l l ( 1 ) ;
var b = new C e l l ( 2 ) ;
var sum = a . b i n d ( f u n c t i o n ( a ) {
return b . bind ( function ( b ) {
r e t u r n new C e l l ( a+b ) ;
}) ;
} ) ; // sum has 3
a . s e t ( 2 ) ; // a has 2, b has 2, sum has 4
b . u n s e t ( ) ; // a has 2, b & sum are unset
..
.
..
.
..
.
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
.
..
.
..
.
..
.
..
.
36. List / ctor
弌仂亰亟舒亠仄 仗亳仂从
var l i s t = new L i s t ( ) ;
..
.
..
.
..
.
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
.
..
.
..
.
..
.
..
.
37. List / ctor()
弌仗亳从 仄仂亢仆仂 仗亠亠亟舒 仆舒舒仍仆亠 亰仆舒亠仆亳 于 从仂仆从仂亠.
var l i s t = new L i s t ( [ 1 , 2 , 3 ] )
..
.
..
.
..
.
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
.
..
.
..
.
..
.
..
.
38. List / add
仍舒亟亠仄 仍亠仄亠仆 于 仗亳仂从
var l i s t = new L i s t ( ) ;
l i s t . add ( " Warp9 " ) ;
l i s t . add ( " React " ) ;
..
.
..
.
..
.
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
.
..
.
..
.
..
.
..
.
39. List / unwrap
仂仍亳 仂亟亠亢亳仄仂亠 仗亳从舒 仄仂亢仆仂 亠亠亰 unwrap
var l i s t = new L i s t ( ) ;
l i s t . add ( " Warp9 " ) ;
c o n s o l e . i n f o ( l i s t . unwrap ( ) ) ;
// [" Warp9 "]
..
.
..
.
..
.
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
.
..
.
..
.
..
.
..
.
40. List / remove
亠仂亟 add 于仂亰于舒舒亠 id 仍亠仄亠仆舒,
仗仂 从仂仂仂仄 亠亞仂 仄仂亢仆仂 亟舒仍亳
var l i s t = new L i s t ( ) ;
var w a r p Id = l i s t . add ( " Warp9 " ) ;
var r e a c t I d = l i s t . add ( " React " ) ;
c o n s o l e . i n f o ( l i s t . unwrap ( ) ) ;
// > [" Warp9 ", " React "]
l i s t . remove ( r e a c t I d ) ;
c o n s o l e . i n f o ( l i s t . unwrap ( ) ) ;
// > [" Warp9 "]
..
.
..
.
..
.
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
.
..
.
..
.
..
.
..
.
41. List / add(了)
丼舒仂 id 仍亠仄亠仆舒 亟仂仍亢亠仆 仂亟亠亢舒 于仆亳 仍亠仄亠仆舒,
仗仂仂仄 仄亠仂亟 add 仄仂亢仆仂 仗亠亠亟舒 仆从亳, 舒 仆从亳
弍亟亠 于亰于舒仆舒, 舒亞仄亠仆仂仄 弍亟亠 id, 舒 于 仗亳仂从 弍亟亠 亟仂弍舒于仍亠仆
亠亰仍舒 于仗仂仍仆亠仆亳 仂亶 仆从亳亳
var l i s t = new L i s t ( ) ;
l i s t . add ( f u n c t i o n ( i d ) {
r e t u r n { i d : i d , name : "Warp" } ;
}) ;
..
.
..
.
..
.
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
.
..
.
..
.
..
.
..
.
42. List / removeWhich
仂仄亠 remove, 亠 亠亠 仂亟亳仆 仄亠仂亟 - removeWhich, 仂仆
仗亳仆亳仄舒亠 仗亠亟亳从舒 亳 亟舒仍磳 亳亰 仗亳从舒 于亠 仍亠仄亠仆,
从仂仂亠 亟仂于仂仍亠于仂ム 仂仄 仗亠亟亳从舒
var l i s t = new L i s t ( [ 1 , 2 , 3 ] ) ;
l i s t . removeWhich ( f u n c t i o n ( x ) {
return x < 2 ;
}) ;
// list contains 2,3
..
.
..
.
..
.
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
.
..
.
..
.
..
.
..
.
43. List / forEach
丐舒从 亢亠 于 仗亳从亠 亠 仄亠仂亟 forEach, 从仂仂亶 于亠亟亠 亠弍 仗仂亟仂弍仆仂
forEach 仄舒亳于舒
var l i s t = new L i s t ( [
" Warp9 " , " React "
]) ;
l i s t . forEach ( function ( x ) {
console . info ( x ) ;
}) ;
// > Warp9
// > React
..
.
..
.
..
.
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
.
..
.
..
.
..
.
..
.
45. List / li
丐舒从 亢亠 从舒从 亳 Cell, 于 List 亠 仄亠仂亟 li, 从仂仂亶 仂亰亟舒亠 仆仂于亶
仗亳仂从 亳 于磶于舒亠 亠亞仂 仆从亳亠亶 亳仂亟仆仄, 仗仂仍舒亠
亠舒从亳于仆亶 map
var a = new L i s t ( ) ;
var b = a . l i f t ( f u n c t i o n ( x ) { r e t u r n x+2 ; } ) ;
// b. unwrap () ==[]
var i d 1 = a . add ( 1 ) ;
// a. unwrap () ==[1] , b. unwrap () ==[3]
var i d 2 = a . add ( 2 ) ;
// a. unwrap () ==[1 ,2] , b. unwrap () ==[3 ,4]
a . remove ( i d 1 ) ;
// a. unwrap () ==[2] , b. unwrap () ==[4]
..
.
..
.
..
.
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
.
..
.
..
.
..
.
..
.
48. List / reduce / sum
亠于亶 仗舒舒仄亠 reduce - 亰仆舒亠仆亳亠, 从仂仂仂亠 仂仂于亠于亠
仗仂仄 仗亳从, 于仂仂亠 亰仆舒亠仆亳亠 - 仆从亳, 从仂仂舒
亰舒仆亳仄舒亠 于亠从仂亶
var l i s t = new L i s t ( ) ;
var sum = l i s t . r e d u c e ( 0 , f u n c t i o n ( a , b ) {
r e t u r n a+b ;
}) ;
l i s t . add ( 4 1 ) ; // sum has 41
l i s t . add ( 1 ) ; // sum has 42
舒从 仄 于亳亟亳仄 仗亠亠仄亠仆仆舒 sum 仗仂仍亳仍舒 亠舒从亳于仆仂亶 亳
亳亰仄亠仆磳 仗亳 亳亰仄亠仆亠仆亳亳 仗亳从舒.
..
.
..
.
..
.
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
.
..
.
..
.
..
.
..
.
50. List / reduce / count
var l i s t = new L i s t ( ) ;
var c o u n t = l i s t . l i f t ( f u n c t i o n ( x ) {
return 1 ;
} ) . reduce ( 0 , function ( a , b ) {
r e t u r n a+b ;
}) ;
var i d 4 1 = l i s t . add ( 4 1 ) ; // count has 1
l i s t . add ( 1 ) ; // count has 2
l i s t . remove ( i d 4 1 ) ; // count has 1
..
.
..
.
..
.
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
.
..
.
..
.
..
.
..
.
51. List / reduce / count / wrap
亅仂 舒弍仂舒ム亳亶 仄亠仂亟, 仗舒于亟舒 亠弍亠 仂亰亟舒仆亳 仆仂于仂亞仂
仗亳从舒; 亠于亠 弍仂仍亠亠 亠从亳于仆亶 仗
var c o u n t = l i s t . r e d u c e ( 0 , f u n c t i o n ( a , b ) {
r e t u r n a+b ;
}, {
wrap : f u n c t i o n ( x ) {
return 1 ;
}
}) ;
..
.
..
.
..
.
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
.
..
.
..
.
..
.
..
.
52. List / wrap
个仆从亳 wrap 于仗仂仍仆磳 亟仍 从舒亢亟仂亞仂 仍亠仄亠仆舒 仗亳从舒 亳 亢亠
亠 亠亰仍舒 舒亞亠亞亳亠, 仂亠于亳亟仆仂, 仂 于仗仂仍仆磳 亰舒从仂仆
f o r a l l ( l i s t , f , id , f o l d ) :
l i s t . r e d u c e ( i d , f o l d , { wrap : f } )
==
l i s t . l i f t ( f ) . reduce ( id , f o l d )
..
.
..
.
..
.
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
.
..
.
..
.
..
.
..
.
54. List / reduceMonoid
仍亳 仗仂仄仂亠 仆舒 亠舒仍亳亰舒亳 仆从亳亳 reduce, 于亳亟仆仂, 仂
于亰仂于 list.reduce(id, fold) 舒从于舒亠 于
l i s t . re d uce Mo n o i d ( {
i d e n t i t y : id ,
add : f o l d
}) ;
从亠仆仆亶 亳舒亠仍 亟仂亞舒亟舒亠, 仂 舒亰 亠 Monoid, 仂 亠
亳 Group, 亳 弍亟亠 仗舒于
..
.
..
.
..
.
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
.
..
.
..
.
..
.
..
.
55. List / reduceGroup
亳仄亠 仄仄仂亶 仍亠仄亠仆仂于 仗亳从舒:
var sum = l i s t . r e d u c e ( 0 , f u n c t i o n ( a , b ) {
r e t u r n a+b ;
}) ;
仄仂亢仆仂 仗亠亠仗亳舒 舒从:
var sum = l i s t . r e d u c e G r o u p ( {
i d e n t i t y : function ( ) { return 0 } ,
add : f u n c t i o n ( a , b ) { r e t u r n a+b ; } ,
i n v e r t : f u n c t i o n ( x ) { r e t u r n x ; }
}) ;
仍仂亢仆仂, 仄舒亞亳亠从亳仄 仂弍舒亰仂仄, 仗舒亟亠 O(ln n) 亟仂 O(1).
仆舒仍仂亞亳仆仂 仄仂亢仆仂 仗仂亳舒 亳 从仂仍-于仂 仍亠仄亠仆仂于 于 仗亳从亠
..
.
..
.
..
.
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
.
..
.
..
.
..
.
..
.
61. List / reduce / unwrap
l i s t . reduceGroup ( {
i d e n t i t y : function ( ) { return [ 0 , 0 ] ; } ,
add : f u n c t i o n ( x , y ) {
r e t u r n [ x [ 0 ]+ y [ 0 ] , x [ 1 ]+ y [ 1 ] ] ;
},
invert : function ( x ) {
r e t u r n [x [ 0 ] , x [ 1 ] ] ;
}
} ,{
wrap : f u n c t i o n ( x ) {
return x ? [ 1 , 1 ] : [ 0 , 1 ] ;
},
unwrap : f u n c t i o n ( x ) {
r e t u r n x [ 0 ]== x [ 1 ] ;
}
}) ;
..
.
..
.
..
.
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
.
..
.
..
.
..
.
..
.
63. List / reduce / Cell
var
var
var
var
l i s t = new L i s t ( ) ;
i t 1 = new C e l l ( 0 ) ;
i t 2 = new C e l l ( 1 ) ;
sum = l i s t . r e d u c e ( 0 , f u n c t i o n ( a , b ) {
return a + b ;
} ) ; // sum has 0
var i t I d 1 = l i s t . add ( i t 1 ) ; // sum has 0
var i t I d 2 = l i s t . add ( i t 2 ) ; // sum has 1
i t 1 . s e t ( 5 ) ; // sum has 6
i t 2 . s e t ( 2 ) ; // sum has 7
i t 1 . u n s e t ( ) ; // sum is unset
l i s t . remove ( i t I d 1 ) ; // sum has 2
..
.
..
.
..
.
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
.
..
.
..
.
..
.
..
.
64. List / reduce / Cell / ignoreUnset
亳亟仆仂, 仂 亠仍亳 于仆亳 亠舒从亳于仆亶 仗亳仂从舒 亠 仗舒
仗亠亠仄亠仆仆舒, 仂 亠亰仍舒 舒亞亠亞舒亳亳 弍亟亠 仗仄. 亅仂
仗仂于亠亟亠仆亳亠 仄仂亢仆仂 亳亰仄亠仆亳: 亟仂舒仂仆仂 于 reduce 仗亠亠亟舒
仂仗亳 ignoreUnset - 于亠 仗亠 仍亠仄亠仆 弍亟 亰舒仄亠仆 仆舒
亠亟亳仆亳仆亶 仍亠仄亠仆 仄仂仆仂亳亟舒 亳仍亳 亞仗仗
var
var
var
var
i t e m 1 = new C e l l ( ) ;
i t e m 2 = new C e l l ( 1 ) ;
l i s t = new L i s t ( [ i t e m 1 , i t e m 2 ] ) ;
sum = l i s t . r e d u c e ( 0 , f u n c t i o n ( a , b ) {
return a + b ;
}, {
ignoreUnset : true
} ) ; // sum has 1
i t e m 1 . s e t ( 3 ) ; // sum has 4
..
.
..
.
..
.
. . . . . . . . . . . .
.. .. .. .. .. .. .. .. .. .. .. .. ..
.
..
.
..
.
..
.
..
.