On Aug 24, 2011, at 9:30 PM, Andrew Pennebaker wrote: > predicate { gen-type1 gen-type2 gen-type3 ... } for-all
The generators needn't be in an array; they could be a simple quotation. Simply calling each generator function in turn will line up their outputs on the stack in the proper order. Assuming the net output effect of the generators is supposed to match the input effect of the predicate, the generators and predicate together would have a constant effect ( -- ? ). The following works, and should be general enough for everything you describe: CONSTANT: number-of-tries 1,000 : for-all? ( generator: ( -- ..a ) predicate: ( ..a -- ? ) -- ? ) [ number-of-tries iota ] 2dip '[ drop @ @ not ] find drop not ; inline ( scratchpad ) [ 2 64 ^ random ] [ even? ] for-all? . f ( scratchpad ) [ 2 64 ^ random 2 * ] [ even? ] for-all? . t : random-string ( -- x ) 32 random [ HEX: 10FFFF random ] "" replicate-as ; ( scratchpad ) [ random-string random-string ] [ [ [ length ] bi@ + ] [ append length ] 2bi = ] for-all? t -Joe
smime.p7s
Description: S/MIME cryptographic signature
------------------------------------------------------------------------------ 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