if you want to keep the "quot { gen1 gen2 ... }" style of declaration,
you can use and modify the following macro:

USING: combinators.smart fry kernel macros math sequences
namespaces ;
IN: forall

: gen-integer ( -- seq ) { 42 } ;
: gen-even ( -- seq ) { 44 } ;
: gen-odd ( -- seq ) { 43 } ;

MACRO: for-all ( quot seq -- quot )
    swap '[ [ execute _ all?  ] curry ] map '[ _ 0&& ]  ;

: foo ( -- f ) [ even? ] { gen-integer gen-odd } for-all ;
: bar ( -- t ) [ even? ] { gen-integer gen-even } for-all ;

you could also save the generator if it fails in a variable in the
for-all macro for later user (eg printing)

Jon

On Thu, Aug 25, 2011 at 9:34 AM, Andrew Pennebaker
<andrew.penneba...@gmail.com> wrote:
> Aha! How could I rewrite for-all? so that it prints the first stack that
> fails the predicate?
> Cheers,
> Andrew Pennebaker
> www.yellosoft.us
> On Thu, Aug 25, 2011 at 1:11 AM, Joe Groff <arc...@gmail.com> wrote:
>>
>> On Aug 24, 2011, at 10:05 PM, Andrew Pennebaker wrote:
>>
>> Joe, your for-all? looks promising (and it's incredibly short). However,
>> when I try it, I'm still getting that macro error.
>>
>> In your "main" you missed the [ ] around prop-even. This line:
>> https://github.com/mcandre/factcheck/blob/master/example.factor#L12
>> should read:
>> [ prop-even ] [ gen-even ] for-all? .
>> -Joe
>>
>> ------------------------------------------------------------------------------
>> EMC VNX: the world's simplest storage, starting under $10K
>> The only unified storage solution that offers unified management
>> Up to 160% more powerful than alternatives and 25% more efficient.
>> Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev
>> _______________________________________________
>> Factor-talk mailing list
>> Factor-talk@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/factor-talk
>>
>
>
> ------------------------------------------------------------------------------
> EMC VNX: the world's simplest storage, starting under $10K
> The only unified storage solution that offers unified management
> Up to 160% more powerful than alternatives and 25% more efficient.
> Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev
> _______________________________________________
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
>

------------------------------------------------------------------------------
EMC VNX: the world's simplest storage, starting under $10K
The only unified storage solution that offers unified management 
Up to 160% more powerful than alternatives and 25% more efficient. 
Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to