Loops/Downward for: Difference between revisions

Content deleted Content added
Rahul (talk | contribs)
Line 47:
[http://www.digitalmars.com/d/2.0/statement.html#ForeachRangeStatement Foreach Range Statement] since D2.003
<d>foreach_reverse(i ; 0..10+1) writefln(i) ;</d>
 
=={{header|dc}}==
 
does not use GNU extensions
 
[] Sp is a comment
 
c clears the stack
 
[~...]p Sp to print strings
 
l<register>x executes the macro
 
uses the macro f - [p] to print, this can be replaced by any complex expressions.
 
c
[macro s(swap) - (a b : b a)] Sp
[Sa Sb La Lb] ss
[macro d(2dup) - (a b : a b a b)] Sp
[Sa d Sb La d Lb lsx] sd
[macro m(for) - ] Sp
[lfx 1 - ldx !<m ] sm
0 10 ldx [p] sf !<m
q
 
Using it
|dc < ./for.dc
10
9
...
0
 
=={{header|Forth}}==