Slava Pestov wrote:

> Here is my version, lest the peanut gallery think that our only took
> for dealing with complexity is locals:
>
> MACRO: deep-cleave-quots ( seq -- quot )
>     [ [ quotation? ] deep-filter ]
>     [ [ dup quotation? [ drop , ] when ] deep-map ]
>     bi '[ _ cleave _ bake ] ;

Alright mr smarty pants. (rolls up sleaves...) ;-)

The existence of 'deep-cleave-quots' implies a 'cleave-quots'. Cleave-quots 
affects only the top-level quotations in the sequence. Here's 'cleave-quots':

    MACRO: cleave-quots ( seq -- quot )
      [ quotations ] [ cleave-quots-recipe ] bi '[ _ cleave _ bake ] ;

And the supporting factors:

    : quotations ( seq -- seq ) [ quotation? ] filter ;

    : quotation-to-comma ( obj -- obj ) dup quotation? [ drop , ] [ ] if ;

    : cleave-quots-recipe ( seq -- seq ) [ quotation-to-comma ] map ;

Now, guess what. 'deep-cleave-quots' can be implemented in terms 
of 'cleave-quots'. So here's *my* solution:

    MACRO: deep-cleave-quots ( seq -- quot )
      [
        [ deep-quotations          ] cleave
        [ deep-cleave-quots-recipe ] bake
      ]
      cleave-quots ;

With supporting factors:

    : deep-quotations ( seq -- quot ) [ quotation? ] deep-filter ;

    : deep-cleave-quots-recipe ( seq -- seq )
      [ quotation-to-comma ] deep-map ;

Boo yah! ;-)

Are we doing the Factor equivalent of rap battles?

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