1 ! Copyright (C) 2008 Alex Chapman
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors arrays kernel math sequences ;
9 : <2merged> ( seq1 seq2 -- merged ) 2array <merged> ;
10 : <3merged> ( seq1 seq2 seq3 -- merged ) 3array <merged> ;
12 : merge ( seqs -- seq )
13 dup <merged> swap first like ;
15 : 2merge ( seq1 seq2 -- seq )
16 dupd <2merged> swap like ;
18 : 3merge ( seq1 seq2 seq3 -- seq )
19 pick [ <3merged> ] dip like ;
21 M: merged length seqs>> [ length ] map sum ;
23 M: merged virtual@ ( n seq -- n' seq' )
24 seqs>> [ length /mod ] [ nth ] bi ;
26 M: merged virtual-seq ( merged -- seq ) [ ] { } map-as ;
28 INSTANCE: merged virtual-sequence