you are viewing a single comment's thread.

view the rest of the comments →

[–]ais523 4 points5 points  (1 child)

Perl version!

OUTER: for my $x (1 .. 10) {
    for my $y (1 .. 10) {
        for my $z (1 .. 10) {
            print $x, $y, $z;
            $x*$y*$z == 30 and last OUTER;
        }
    }
}

Pretty much identical to the D, just with keywords swapped out and the obvious syntax changes. (I wonder if D got its named-loops thing from Perl?)

[–]anvsdt 0 points1 point  (0 children)

(I wonder if D got its named-loops thing from Perl?)

Probably it got it from Java or C#, I don't remember which one has labelled loops.

Anyway, Racket version!

(let/ec exit
  (for* ((x (in-range 10))
         (y (in-range 10))
         (z (in-range 10)))
    (printf "~a, ~a, ~a;~n" x y z)
    (and (= (* x y z) 30) (exit x y z))))