Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
|
|
@ -1,5 +1,8 @@
|
|||
{{omit from|GUISS}}
|
||||
{{omit from|M4}}
|
||||
Show the following output using one loop.
|
||||
1, 2, 3, 4, 5
|
||||
6, 7, 8, 9, 10
|
||||
|
||||
Try to achieve the result by forcing the next iteration within the loop upon a specific condition, if your language allows it.
|
||||
Try to achieve the result by forcing the next iteration within the loop
|
||||
upon a specific condition, if your language allows it.
|
||||
|
|
|
|||
|
|
@ -1,2 +1,4 @@
|
|||
---
|
||||
category:
|
||||
- Loop modifiers
|
||||
note: Iteration
|
||||
|
|
|
|||
|
|
@ -1,13 +1,17 @@
|
|||
with Ada.Text_Io; use Ada.Text_Io;
|
||||
with Ada.Text_IO;
|
||||
use Ada.Text_IO;
|
||||
|
||||
procedure Loop_Continue is
|
||||
begin
|
||||
for I in 1..10 loop
|
||||
Put(Integer'Image(I));
|
||||
if I mod 5 = 0 then
|
||||
New_Line;
|
||||
else
|
||||
Put(",");
|
||||
end if;
|
||||
end loop;
|
||||
for I in 1..10 loop
|
||||
Put (Integer'Image(I));
|
||||
if I = 5 or I = 10 then
|
||||
New_Line;
|
||||
goto Continue;
|
||||
end if;
|
||||
Put (",");
|
||||
-- label must be followed by a statement.
|
||||
<<Continue>>
|
||||
null;
|
||||
end loop;
|
||||
end Loop_Continue;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
10 FOR I = 1 TO 10
|
||||
20 PRINT I;
|
||||
30 IF I - INT (I / 5) * 5 = 0 THEN PRINT : GOTO 50"CONTINUE
|
||||
40 PRINT ", ";
|
||||
50 NEXT
|
||||
5
Task/Loops-Continue/Clojure/loops-continue-1.clj
Normal file
5
Task/Loops-Continue/Clojure/loops-continue-1.clj
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
(doseq [n (range 1 11)]
|
||||
(print n)
|
||||
(if (zero? (rem n 5))
|
||||
(println)
|
||||
(print ", ")))
|
||||
7
Task/Loops-Continue/Clojure/loops-continue-2.clj
Normal file
7
Task/Loops-Continue/Clojure/loops-continue-2.clj
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
(loop [xs (range 1 11)]
|
||||
(when-let [x (first xs)]
|
||||
(print x)
|
||||
(if (zero? (rem x 5))
|
||||
(println)
|
||||
(print ", "))
|
||||
(recur (rest xs))))
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
(doseq
|
||||
[n (range 1 11)]
|
||||
(do
|
||||
(print n)
|
||||
(if (= (rem n 5) 0) (print "\n") (print ", "))))
|
||||
5
Task/Loops-Continue/NewLISP/loops-continue.newlisp
Normal file
5
Task/Loops-Continue/NewLISP/loops-continue.newlisp
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
(for (i 1 10)
|
||||
(print i)
|
||||
(if (= 0 (% i 5))
|
||||
(println)
|
||||
(print ", ")))
|
||||
|
|
@ -1 +1 @@
|
|||
1.upto(10) {|i| print "%d%s" % [i, i%5==0 ? "\n" : ", "]}
|
||||
(1..10).each_slice(5){|ar| puts ar.join(", ")}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue