Set consolidation: Difference between revisions

Content added Content deleted
(Add Factor)
Line 818:
<lang factor>USING: arrays kernel sequences sets ;
 
DEFER: comb ( x x -- x )
: comb ( x x -- x ) over empty? [ nip 1array ] [ (comb) ] if ;
 
dup pick first intersects?
: (comb) ( x x -- x )
[ [ unclip ] dip union comb ]
dup pick first intersects?
[ [ [ rest ][ [ first1 ] bicut ] dip union comb append ] if
] if ;
[ [ [ first 1array ] [ rest ] bi ] dip comb append ] if ;
 
: comb ( x x -- x ) over empty? [ nip 1array ] [ (comb) ] if ;
 
: consolidate ( x -- x ) { } [ comb ] reduce ;</lang>