Loops/Wrong ranges: Difference between revisions

Content deleted Content added
PureFox (talk | contribs)
Added C
Thundergnat (talk | contribs)
m →‎{{header|Perl 6}}: at this point I'm just screwin' around.
Line 268: Line 268:


Also note: The iterator function for the sequence is literally a function. It is any expression that produces a value. These sequences all use simple arithmatic increments but that is not a limitation of the sequence operator.
Also note: The iterator function for the sequence is literally a function. It is any expression that produces a value. These sequences all use simple arithmatic increments but that is not a limitation of the sequence operator.



<lang perl6># Given sequence definitions
<lang perl6># Given sequence definitions
Line 304: Line 303:
say [0,1,2,3,4,5], *.rotate(-1) … !*.tail;
say [0,1,2,3,4,5], *.rotate(-1) … !*.tail;


# Iterate through strings.
# Iterate strings backwards.
put 'a' … 'h';</lang>
put 'xp' … 'xf';</lang>
{{out}}
{{out}}
<pre>Start: -2, Stop: 2, Increment: 1 | -2 -1 1 2
<pre>Start: -2, Stop: 2, Increment: 1 | -2 -1 1 2
Line 321: Line 320:
1 -0.5 1.4142135623730951 -0.7071067811865476 0.5000000000000001 -0.5000000000000002 0.176776695296637 -0.04419417382415928 0.0039062500000000095
1 -0.5 1.4142135623730951 -0.7071067811865476 0.5000000000000001 -0.5000000000000002 0.176776695296637 -0.04419417382415928 0.0039062500000000095
([0 1 2 3 4 5] [5 0 1 2 3 4] [4 5 0 1 2 3] [3 4 5 0 1 2] [2 3 4 5 0 1] [1 2 3 4 5 0])
([0 1 2 3 4 5] [5 0 1 2 3 4] [4 5 0 1 2 3] [3 4 5 0 1 2] [2 3 4 5 0 1] [1 2 3 4 5 0])
a b c d e f g h</pre>
xp xo xn xm xl xk xj xi xh xg xf</pre>


=={{header|Python}}==
=={{header|Python}}==