Anonymous user
Repeat: Difference between revisions
Examples now in alphabetical order. Made a draft task (I presume that was wanted)?
(created in three langs, in incorrect alphabetical order) |
(Examples now in alphabetical order. Made a draft task (I presume that was wanted)?) |
||
Line 1:
{{draft task}}
The task is to write a procedure
=={{header|
<lang
#include <stdio.h>▼
#!/usr/bin/python▼
def repeat(f,n):▼
for i in range(n):▼
f();▼
void repeat(void (*f)(void), int n) {▼
def procedure():▼
for(int i=n; 0<i; i--)▼
print("Example");▼
(*f)();▼
}▼
void example() {▼
repeat(procedure,3); #prints "Example" (without quotes) three times, separated by newlines.▼
printf("Example\n");▼
}▼
void main(char *argv[], int argc) {▼
repeat(example, 4);▼
}▼
</lang>
=={{header|Haskell}}==
<lang Haskell>
Line 26 ⟶ 33:
</lang>
=={{header|
<lang
▲#!/usr/bin/python
▲#include <stdio.h>
▲def repeat(f,n):
▲ for i in range(n):
▲ f();
▲def procedure():
▲void repeat(void (*f)(void), int n) {
▲ print("Example");
▲ for(int i=n; 0<i; i--)
▲ (*f)();
▲}
▲repeat(procedure,3); #prints "Example" (without quotes) three times, separated by newlines.
▲void example() {
▲ printf("Example\n");
▲}
▲void main(char *argv[], int argc) {
▲ repeat(example, 4);
▲}
</lang>
|