This commit is contained in:
Ingy döt Net 2013-10-27 22:24:23 +00:00
parent 6f050a029e
commit 776bba907c
3887 changed files with 59894 additions and 7280 deletions

View file

@ -0,0 +1,9 @@
integer i;
i = 0;
while (i < 10) {
o_winteger(2, i);
i += 2;
}
o_newline();

View file

@ -0,0 +1,14 @@
IDENTIFICATION DIVISION.
PROGRAM-ID. Display-Odd-Nums.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 I PIC 99.
PROCEDURE DIVISION.
PERFORM VARYING I FROM 1 BY 2 UNTIL 10 < I
DISPLAY I
END-PERFORM
GOBACK
.

View file

@ -1,3 +1 @@
(loop for i from 2 to 8 by 2 do
(format t "~d, " i))
(format t "who do we appreciate?~%")
(format t "~{~S, ~}who do we appreciate?~%" (loop for i from 2 to 8 by 2 collect i))

View file

@ -1,15 +1,17 @@
%% Implemented by Arjun Sunel
%% for_loop/4 by Bengt Kleberg.
-module(loop_step).
-export([main/0, for_loop/1]).
-export([main/0, for_loop/1, for_loop/4]).
% This Erlang code for "For Loop" is equivalent to: " for (i=start; i<end ; i=i+2){ printf("* ");} " in C language.
main() ->
for_loop(1).
for_loop(N) when N < 4 ->
io:fwrite("* "),
for_loop(N+2);
for_loop(N) when N >= 4->
io:format("").
for_loop( N ) ->
for_loop( N, 4, 2, fun() -> io:fwrite("* ") end ).
for_loop( I, End, Step, Do ) when N < End ->
Do(),
for_loop( I+Step, End, Step, Do );
for_loop( _I, _End, _Step, _Do ) -> ok.

View file

@ -0,0 +1 @@
for x in countdown(10,0,3): echo(x)