Add call-with and call-with2 to combinators.lib, which act like map-call-with except they do not collect the results into an array

db4
Joe Groff 2008-01-20 10:08:36 -08:00
parent 5e48afda60
commit c5f0829b09
1 changed files with 15 additions and 5 deletions
extra/combinators/lib

View File

@ -173,14 +173,24 @@ MACRO: parallel-call ( quots -- )
! map-call and friends
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
: (make-call-with) ( quots -- quot )
[ [ keep ] curry ] map concat [ drop ] append ;
MACRO: call-with ( quots -- )
(make-call-with) ;
MACRO: map-call-with ( quots -- )
[ [ [ keep ] curry ] map concat ] keep length [ nip narray ] curry compose ;
[ (make-call-with) ] keep length [ narray ] curry compose ;
: (make-call-with2) ( quots -- quot )
[ [ 2dup >r >r ] swap append [ r> r> ] append ] map concat
[ 2drop ] append ;
MACRO: call-with2 ( quots -- )
(make-call-with2) ;
MACRO: map-call-with2 ( quots -- )
dup >r
[ [ 2dup >r >r ] swap append [ r> r> ] append ] map concat
[ 2drop ] append
r> length [ narray ] curry append ;
dup >r (make-call-with2) r> length [ narray ] curry append ;
MACRO: map-exec-with ( words -- ) [ 1quotation ] map [ map-call-with ] curry ;