Loops/With multiple ranges: Difference between revisions
Content added Content deleted
(Added Kotlin) |
SqrtNegInf (talk | contribs) m (→{{header|Perl 6}}: alternate method for generating the 'j' sequence) |
||
Line 272: | Line 272: | ||
Sum: 348,173 |
Sum: 348,173 |
||
Product: -793,618,560</pre> |
Product: -793,618,560</pre> |
||
==== Literal-minded variation ==== |
|||
An alternate method for generating the 'j' sequence, employing user-defined operators to preserve the 'X to Y by Z' layout of the example code. |
|||
<lang perl6>sub infix:<to> { $^a...$^b } |
|||
sub infix:<by> { ($^a.split(' '))[0,$^b.abs ... *] } |
|||
$j = flat |
|||
-three to 3**3 by three , |
|||
-seven to seven by x , |
|||
555 to (550 - y) , |
|||
22 to -28 by -three , |
|||
1927 to 1939 by one , |
|||
x to y by z , |
|||
11**x to (11**x+one);</lang> |
|||
=={{header|REXX}}== |
=={{header|REXX}}== |