Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
31
Task/Nested-function/Cowgol/nested-function.cowgol
Normal file
31
Task/Nested-function/Cowgol/nested-function.cowgol
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
include "cowgol.coh";
|
||||
include "strings.coh";
|
||||
|
||||
sub MakeList(sep: [uint8], buf: [uint8]): (out: [uint8]) is
|
||||
out := buf; # return begin of buffer for ease of use
|
||||
var counter: uint32 := 0;
|
||||
|
||||
# Add item to string
|
||||
sub AddStr(str: [uint8]) is
|
||||
var length := StrLen(str);
|
||||
MemCopy(str, length, buf);
|
||||
buf := buf + length;
|
||||
end sub;
|
||||
|
||||
sub MakeItem(item: [uint8]) is
|
||||
counter := counter + 1;
|
||||
buf := UIToA(counter, 10, buf);
|
||||
AddStr(sep);
|
||||
AddStr(item);
|
||||
AddStr("\n");
|
||||
end sub;
|
||||
|
||||
MakeItem("first");
|
||||
MakeItem("second");
|
||||
MakeItem("third");
|
||||
[buf] := 0; # terminate string
|
||||
end sub;
|
||||
|
||||
var buffer: uint8[100];
|
||||
|
||||
print(MakeList(". ", &buffer as [uint8]));
|
||||
Loading…
Add table
Add a link
Reference in a new issue