change produce-as so it uses an intermediate vector of a type appropriate to the destination type

db4
Joe Groff 2009-10-22 14:35:27 -05:00
parent 6e22945d41
commit fdea9b09f2
1 changed files with 5 additions and 2 deletions

View File

@ -498,11 +498,14 @@ PRIVATE>
: partition ( seq quot -- trueseq falseseq )
over [ 2pusher [ each ] 2dip ] dip [ like ] curry bi@ ; inline
: accumulator-for ( quot exemplar -- quot' vec )
[ length ] keep new-resizable [ [ push ] curry compose ] keep ; inline
: accumulator ( quot -- quot' vec )
V{ } clone [ [ push ] curry compose ] keep ; inline
V{ } accumulator-for ; inline
: produce-as ( pred quot exemplar -- seq )
[ accumulator [ while ] dip ] dip like ; inline
dup '[ _ accumulator-for [ while ] dip ] dip like ; inline
: produce ( pred quot -- seq )
{ } produce-as ; inline