Loops/With multiple ranges: Difference between revisions

Content deleted Content added
Wherrera (talk | contribs)
Line 305:
prod = -793,618,560
</pre>
 
=={{header|Julia}}==
Julia allows merging of iterators, but only as collected into a single vector. An attempt was made to preserve the shape of the PL/1 code.
<lang julia>function PL1example()
 
# all variables are DECLARED as integers.
prod = 1; # start with a product of unity.
sum = 0; # " " " sum " zero.
x = +5;
y = -5;
z = -2;
one = 1;
three = 3;
seven = 7;
# (below) ** is exponentiation: 4**3=64
for j in vcat(collect( -three : three : 3^3 ),
collect( -seven : x : +seven ),
collect( 555 : 550 - y ),
collect( 22 : -three : -28 ),
collect( 1927 : 1939 ),
collect( x : z : y ),
collect( 11^x : 11^x + one ))
# ABS(n) = absolute value
sum = sum + abs(j); # add absolute value of J.
if abs(prod) < 2^27 && j !=0 prod = prod*j # PROD is small enough & J
end; # not 0, then multiply it.
end # SUM and PROD are used for verification of J incrementation.
println(" sum = $sum"); # display strings to term.
println("prod = $prod"); # " " " "
end
 
PL1example()
</lang> {{output}} <pre>
sum = 348173
prod = -793618560
</pre>
 
 
=={{header|Kotlin}}==