Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
8
Task/Integer-sequence/Cowgol/integer-sequence-1.cowgol
Normal file
8
Task/Integer-sequence/Cowgol/integer-sequence-1.cowgol
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
include "cowgol.coh";
|
||||
|
||||
var n: uint32 := 1;
|
||||
while n != 0 loop;
|
||||
print_i32(n);
|
||||
print_nl();
|
||||
n := n + 1;
|
||||
end loop;
|
||||
45
Task/Integer-sequence/Cowgol/integer-sequence-2.cowgol
Normal file
45
Task/Integer-sequence/Cowgol/integer-sequence-2.cowgol
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
include "cowgol.coh";
|
||||
|
||||
sub print_back(s: [uint8]) is
|
||||
while [s] != 0 loop;
|
||||
print_char([s]);
|
||||
s := @prev s;
|
||||
end loop;
|
||||
print_nl();
|
||||
end sub;
|
||||
|
||||
sub incr(n: [uint8]): (r: [uint8]) is
|
||||
r := n;
|
||||
while [n] != 0 loop;
|
||||
n := @prev n;
|
||||
end loop;
|
||||
n := @next n;
|
||||
loop
|
||||
if [n] == 0 then
|
||||
[n] := '1';
|
||||
[@next n] := 0;
|
||||
r := n;
|
||||
break;
|
||||
elseif [n] == '9' then
|
||||
[n] := '0';
|
||||
n := @next n;
|
||||
continue;
|
||||
else
|
||||
[n] := [n] + 1;
|
||||
break;
|
||||
end if;
|
||||
end loop;
|
||||
end sub;
|
||||
|
||||
sub init(n: [uint8]): (r: [uint8]) is
|
||||
[n] := 0;
|
||||
[n+1] := '0';
|
||||
[n+2] := 0;
|
||||
r := n+1;
|
||||
end sub;
|
||||
|
||||
var infnum := init(LOMEM);
|
||||
loop
|
||||
infnum := incr(infnum);
|
||||
print_back(infnum);
|
||||
end loop;
|
||||
Loading…
Add table
Add a link
Reference in a new issue