factor: rename all three of the {foo} words.
parent
c42de83132
commit
ce415c5184
|
@ -59,7 +59,7 @@ DEFER: in-rect*
|
|||
: ur-bounds ( rect -- rect' )
|
||||
[ [ loc>> ] [ dim>> { 0.5 0.5 } v* ] bi v+ ] [ child-dim ] bi <rect> ;
|
||||
|
||||
: {quadrants} ( node -- quadrants )
|
||||
: node>quadrants ( node -- quadrants )
|
||||
{ [ ll>> ] [ lr>> ] [ ul>> ] [ ur>> ] } cleave 4array ;
|
||||
|
||||
: add-subnodes ( node -- node )
|
||||
|
@ -130,7 +130,7 @@ DEFER: in-rect*
|
|||
} case ;
|
||||
|
||||
: collapseable? ( node -- {point,value}/f )
|
||||
{quadrants} { [ [ leaf?>> ] all? ] [ ?leaf ] } 1&& ;
|
||||
node>quadrants { [ [ leaf?>> ] all? ] [ ?leaf ] } 1&& ;
|
||||
|
||||
: remove-subnodes ( node -- leaf ) f >>ll f >>lr f >>ul f >>ur t >>leaf? ;
|
||||
|
||||
|
@ -162,7 +162,7 @@ DEFER: in-rect*
|
|||
|
||||
: leaf= ( a b -- ? ) [ [ point>> ] [ value>> ] bi 2array ] same? ;
|
||||
|
||||
: node= ( a b -- ? ) [ {quadrants} ] same? ;
|
||||
: node= ( a b -- ? ) [ node>quadrants ] same? ;
|
||||
|
||||
: (tree=) ( a b -- ? ) dup leaf?>> [ leaf= ] [ node= ] if ;
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ TUPLE: foo a b c ;
|
|||
|
||||
{ { 2 1 3 } } [
|
||||
T{ foo { a 1 } { b 2 } { c 3 } }
|
||||
{ "b" "a" "c" } {slots}
|
||||
{ "b" "a" "c" } slots>array
|
||||
] unit-test
|
||||
|
||||
{ T{ foo { a "one" } { b "two" } { c "three" } } } [
|
||||
|
@ -70,5 +70,5 @@ TUPLE: foo a b c ;
|
|||
{ T{ foo { a "one" } { b "two" } { c "three" } } } [
|
||||
{ "two" "one" "three" }
|
||||
T{ foo { a 1 } { b 2 } { c 3 } } clone
|
||||
[ { "b" "a" "c" } {set-slots} ] keep
|
||||
[ { "b" "a" "c" } set-tuple-slots ] keep
|
||||
] unit-test
|
||||
|
|
|
@ -44,12 +44,12 @@ MACRO: set-slot ( name -- quot: ( value tuple -- ) )
|
|||
MACRO: slots ( names -- quot: ( tuple -- values... ) )
|
||||
[ '[ _ slot ] ] { } map-as '[ _ cleave ] ;
|
||||
|
||||
MACRO: {slots} ( names -- quot: ( tuple -- {values} ) )
|
||||
MACRO: slots>array ( names -- quot: ( tuple -- values ) )
|
||||
dup length '[ _ slots _ narray ] ;
|
||||
|
||||
MACRO: set-slots ( names -- quot: ( values... tuple -- ) )
|
||||
[ [ '[ _ set-slot ] ] [ ] map-as ] [ length dup ] bi
|
||||
'[ @ _ cleave-curry _ spread* ] ;
|
||||
|
||||
MACRO: {set-slots} ( names -- quot: ( {values} tuple -- ) )
|
||||
MACRO: set-tuple-slots ( names -- quot: ( values tuple -- ) )
|
||||
[ length ] keep '[ [ _ firstn ] dip _ set-slots ] ;
|
||||
|
|
Loading…
Reference in New Issue