Re: forany, forall...
On Sun, Jan 16, 2005 at 09:27:56PM -0800, Jonathan Lang wrote: > How would I do the following in Perl 6? Modulo any syntax foibles, I think it'd look like this: > > if a given condition is true for every element in a list, do something. if all(LIST) > 3 { do_something } > > or > > if a given condition is true for any element in a list, do something. if any(LIST) > 3 { do_something } Where LIST is, of course, the actual list of things. The exact syntax of the conditional would change with what you wish to test. if all(LIST) ~~ /foo/ { do_something } if 7 < all(LIST) < 15 { do_something } if all(LIST) eq 'fred' { do_something } -Scott -- Jonathan Scott Duff [EMAIL PROTECTED]
Re: forany, forall...
Both of your questions are quite elegantly handled by junctions. If the condition were, say, $elem > 10: Jonathan Lang <[EMAIL PROTECTED]> wrote: > if a given condition is true for every element in a list, do something. if all(@list) > 10 { ... } > if a given condition is true for any element in a list, do something. if any(@list) > 10 { ... } -- Brent 'Dax' Royal-Gordon <[EMAIL PROTECTED]> Perl and Parrot hacker "For those of you that can't spell, this site also contains free imags, iamges, imges, picturs, pcitures, picktures, picturess, and pistures."
forany, forall...
How would I do the following in Perl 6? if a given condition is true for every element in a list, do something. or if a given condition is true for any element in a list, do something. = Jonathan "Dataweaver" Lang __ Do you Yahoo!? Yahoo! Mail - Helps protect you from nasty viruses. http://promotions.yahoo.com/new_mail