Loops/With multiple ranges: Difference between revisions
Content added Content deleted
m (→{{header|J}}: a minor caveat) |
Drkameleon (talk | contribs) (added Arturo) |
||
Line 763: | Line 763: | ||
-793618560 |
-793618560 |
||
</pre> |
</pre> |
||
=={{header|Arturo}}== |
|||
<syntaxhighlight lang="arturo">multiLoop: function [ranges, it, blk][ |
|||
loop ranges 'rng [ |
|||
loop rng 'r [ |
|||
let it r |
|||
do blk |
|||
] |
|||
] |
|||
] |
|||
x: 5 |
|||
y: neg 5 |
|||
z: neg 2 |
|||
one: 1 |
|||
three: 3 |
|||
seven: 7 |
|||
totalSum: 0 |
|||
totalProduct: 1 |
|||
multiLoop @[ |
|||
range.step:three neg three 3^3 |
|||
range.step:x neg seven seven |
|||
range 555 550-y |
|||
range.step:neg three 22 neg 28 |
|||
range 1927 1939 |
|||
range.step: z x y |
|||
range 11^x 1+11^x |
|||
] 'i [ |
|||
totalSum: totalSum + abs i |
|||
if and? (abs totalProduct) < 2^27 |
|||
i <> 0 -> |
|||
totalProduct: totalProduct * i |
|||
] |
|||
print ["Sum:" totalSum] |
|||
print ["Product:" totalProduct]</syntaxhighlight> |
|||
{{out}} |
|||
<pre>Sum: 348173 |
|||
Product: -793618560</pre> |
|||
=={{header|AutoHotkey}}== |
=={{header|AutoHotkey}}== |
||
Line 804: | Line 847: | ||
<pre>sum = 348,173 |
<pre>sum = 348,173 |
||
prod = -793,618,560</pre> |
prod = -793,618,560</pre> |
||
=={{header|AWK}}== |
=={{header|AWK}}== |
||
<syntaxhighlight lang="awk"> |
<syntaxhighlight lang="awk"> |