Talk:Loops/While: Difference between revisions

m
added a section header to the first topic to properly place the table-of-contents (TOC) --- (this happens more often than one would think).
(→‎REXX: added a comment. -- ~~~~)
m (added a section header to the first topic to properly place the table-of-contents (TOC) --- (this happens more often than one would think).)
 
(5 intermediate revisions by 2 users not shown)
Line 1:
== number should be INT ? ==
 
Perhaps it should be specified that the number should be int or the number to count down to should be '1' rather than '0' The reason is that for languages that support the numbers rather than integers, the value only tends towards '0' never reaching it :)
 
Line 38 ⟶ 40:
 
::: And what ... just leave the ridiculous and incorrect REXX program there (and for how long?).   It serves nobody to have such an erroreous program on Rosetta Code that shows no worthwhile (or even correct) "solution". -- [[User:Gerard Schildberger|Gerard Schildberger]] ([[User talk:Gerard Schildberger|talk]]) 22:11, 30 October 2013 (UTC)
 
:::: NO. just delete it (that's what I did). It serves nobody... --[[User:Walterpachl|Walterpachl]] ([[User talk:Walterpachl|talk]]) 12:23, 31 October 2013 (UTC)
 
<br> sorry for interfering.
<br>Could Siskus pls comment about his or her intentions here??? --[[User:Walterpachl|Walterpachl]] ([[User talk:Walterpachl|talk]]) 22:03, 30 October 2013 (UTC)
 
== DC ==
 
The DC solution looks like a DO-UNTIL loop rather than a WHILE.
<pre>
$ dc -e '_4[p2/d0<p]dspx'
-4
</pre>
A WHILE should test first and execute the body only if the test succeeded.
 
Alternative version (needs review, comment, adopt, ...):
 
{{works with|GNU Dc}}
{{works with|OpenBSD Dc}}
If the comments are omitted: {{works with|AT&T Dc}}
<pre>
$ dc<<end
[ q ] sQ # makro Q : quit 2 levels (quit Q and calling level)
1024 [ d 0!<Q # compare, quit if true
p 2 / # print and divide
lW x # tail recursion
] d sW x # duplicate store as W execute TOS
end
1024
512
256
128
64
32
16
8
4
2
1
</pre>
 
--[[User:Yeti|Yeti]] ([[User talk:Yeti|talk]]) 04:42, 26 November 2018 (UTC)