Hello,

Here are generalized versions of 'spread' and 'spread-with':

----------------------------------------------------------------------
: [nspread] ( quots n -- )
  [ swap length * [ drop [ >r ] ] map concat ]
  [ [ drop [ r> ] ] map concat swap [ append ] with map concat ] 2bi
  append ;

MACRO: nspread ( quots n -- ) [nspread] ;
----------------------------------------------------------------------
: [mspread-withn] ( quots n m -- )
  swap >r dup >r [ ncurry ] curry r> nwith map r> [nspread] ;

MACRO: mspread-withn ( quots m n -- ) [mspread-withn] ;
----------------------------------------------------------------------

I propose 'bi%' to mean 'spread-with'. The definition in terms of the above:

        : [bi%] ( p q -- quot ) 2array 1 1 [mspread-withn] ;

        MACRO: bi% ( p q -- quot ) [bi%] ;

The arities implied in the name 'bi%' are 1 and 1. The arity of the spread is 
1 because you are spreading over the stack elements in units of 1. The arity 
of the with is 1 because we're spreading "with" one item.

Ed

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to