Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
25
Task/Repeat/ALGOL-68/repeat.alg
Normal file
25
Task/Repeat/ALGOL-68/repeat.alg
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
# operator that executes a procedure the specified number of times #
|
||||
OP REPEAT = ( INT count, PROC VOID routine )VOID:
|
||||
TO count DO routine OD;
|
||||
|
||||
# make REPEAT a low priority operater #
|
||||
PRIO REPEAT = 1;
|
||||
|
||||
|
||||
# can also create variant that passes the iteration count as a parameter #
|
||||
OP REPEAT = ( INT count, PROC( INT )VOID routine )VOID:
|
||||
FOR iteration TO count DO routine( iteration ) OD;
|
||||
|
||||
main: (
|
||||
|
||||
# PROC to test the REPEAT operator with #
|
||||
PROC say something = VOID: print( ( "something", newline ) );
|
||||
|
||||
3 REPEAT say something;
|
||||
|
||||
# PROC to test the variant #
|
||||
PROC show squares = ( INT n )VOID: print( ( n, n * n, newline ) );
|
||||
|
||||
3 REPEAT show squares
|
||||
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue