Anonymous user
Loops/While: Difference between revisions
added scheme
(added scheme) |
|||
Line 125:
n := !n / 2
done;;</ocaml>
But it is more common to write it in a tail-recursive functional style:
<ocaml>let rec loop n =
if n > 0 then begin
Printf.printf "%d\n" n;
loop (n / 2)
end
in loop 1024</ocaml>
=={{header|Pascal}}==
Line 164 ⟶ 172:
print n
n = n / 2</python>
=={{header|Scheme}}==
<scheme>
(do ((n 1024 (quotient n 2)))
((<= n 0))
(display n)
(newline))</scheme>
=={{header|UnixPipes}}==
|