Damian Conway wrote:

Seiler Thomas wrote:

So... lets call a function instead:

    my $is_ok = 1;
    for 0..6 -> $t {
        if abs(@new[$t] - @new[$t+1]) > 3 {
            $is_ok = 0;
            last;
        }
    }
    if $is_ok {
        yada()  # has sideeffects...
    }



That's just:


    for 0..6, 'ok' -> $t {
        when 'ok' { yada() }
        last if abs(@new[$t] - @new[$t+1]) > 3;
    }

;-)

Damian


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...
   }

:)

- Joe



Reply via email to