develooper Front page | perl.perl6.language | Postings from November 2003

Re: Control flow variables

Thread Previous | Thread Next
From:
David Wheeler
Date:
November 18, 2003 18:35
Subject:
Re: Control flow variables
Message ID:
1BCB0CC8-1A39-11D8-9CB5-0003931A964A@kineticode.com
On Tuesday, November 18, 2003, at 06:11  PM, Joseph Ryan wrote:

> Not to be a jerk, but how about:
>
>    my $is_ok = 1;
>    for @array_of_random_values_and_types -> $t {
>        if not some_sort_of_test($t) {
>            $is_ok = 0;
>            last;
>        }
>    }
>    if $is_ok {
>        yada() # has sideeffects...
>    }

Isn't that just:

     for @array_of_random_values_and_types, 'ok' -> $t {
         when 'ok' { yada(); last }
         last unless some_sort_of_test($t);
     }

IOW, the topic is only 'ok' when all of the items in the array have 
been processed, which in your code is what happens when  
some_sort_of_test($t) returns a true value.

Regards,

David

-- 
David Wheeler                                     AIM: dwTheory
david@kineticode.com                              ICQ: 15726394
http://www.kineticode.com/                     Yahoo!: dew7e
                                                Jabber: Theory@jabber.org
Kineticode. Setting knowledge in motion.[sm]


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About