Paul Moore <[email protected]> wrote: > William Tanksley, Jr <[email protected]>: >> It was a recent discussion on this group -- either search your gmail >> (which I see you're using), or use sourceforge's email list search.
> Hmm, couldn't find it searching for "nowak" or "banana". And my > personal gmail archive isn't particularly old, so I don't have it in > there. Never mind, I'll search more later. (I'd forgotten just how > badly SF email sucks :-( ) DARN! That discussion was on the 'concatenative' mailing list, not on factor-talk. Tell you what, I feel bad, so as the moderator of that mailing list I'll give you, absolutely FREE, a copy of the information in the original message. (Offer not valid in all jurisdictions. Some restrictions may apply.) Seriously, though, I feel stupid. Sorry. Here (after my .sig) is a repost. I also suggested a (- -) syntax which did for 'cleave' what (| |) does for 'spread'. Of course, once you start down that road, you start wanting to nest them, and then forever will it dominate your destiny, consume you it will. (Note that I'm aware that this doesn't replicate 'spread' -- there are big differences. I like it because it removes the need for all the numbered and sigiled variants) > Paul. -Wm --- John Nowak <[email protected]> to concatenative <[email protected]> date Mon, Jan 5, 2009 at 1:28 AM subject [stack] improved parallel combinator mailing list <concatenative.yahoogroups.com> I actually really like this one. No more weird pseudo-vector stuff. Here are the semantics: S (| F |) == S F S (| F , G |) == S F { S G } peek S (| F , G , H |) == S F { S G } peek { S H } peek .. Here are some examples: 5 (| sq , neg |) == 25 -5 4 3 (| + , * |) == 7 12 1 2 (| nip , drop |) == 2 1 ! same as 'swap' { 2 3 4 } (| rest , first |) == { 3 4 } 2 ! same as 'unclip' Here is the implementation: : infra-seq ( seq seq -- seq ) [ [ with-datastack peek ] curry keep ] each drop ; : datastack-tail ( x -- x seq ) [ datastack ] dip swap ; : parallel ( seq -- ) datastack-tail [ unclip dip ] dip swap infra-seq ; ! "banana syntax" for 'parallel': ! (| F , G |) == { [ F ] [ G ] } parallel : |) ; : (| \ |) [ \ , 1array split [ >quotation ] map ] parse-literal \ parallel suffix ; parsing For those not familiar with Factor: { x0 .. xN } peek == xN { x S } unclip == { S } x [ F ] x slip == F x { S } [ F ] with-datastack == { S F } The trick was realizing that the first quotation should be applied directly to the main stack. Lacking this, you'd need to explicitly indicate how many values to pass to each function (as with '2cleave', '3cleave', etc). The only downside of this form compared to the previous one is that you need to explicitly group values if you want to return more than one from one of the functions (except for the first). I don't see this as a big problem. - John ------------------------------------------------------------------------------ This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword _______________________________________________ Factor-talk mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/factor-talk
