Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
23
Task/Repeat/Cowgol/repeat.cowgol
Normal file
23
Task/Repeat/Cowgol/repeat.cowgol
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
include "cowgol.coh";
|
||||
|
||||
# Only functions that implement an interface can be passed around
|
||||
# The interface is a type and must be defined before it is used
|
||||
# This defines an interface for a function that takes no arguments
|
||||
interface Fn();
|
||||
|
||||
# This function repeats a function that implements Fn
|
||||
sub Repeat(f: Fn, n: uint32) is
|
||||
while n != 0 loop
|
||||
f();
|
||||
n := n - 1;
|
||||
end loop;
|
||||
end sub;
|
||||
|
||||
# Here is a function
|
||||
sub Foo implements Fn is
|
||||
print("foo ");
|
||||
end sub;
|
||||
|
||||
# Prints "foo foo foo foo"
|
||||
Repeat(Foo, 4);
|
||||
print_nl();
|
||||
Loading…
Add table
Add a link
Reference in a new issue