Repeat: Difference between revisions
m
Create a repetition example in Mastermind.
m (→{{header|Wren}}: Changed to Wren S/H) |
m (Create a repetition example in Mastermind.) |
||
Line 1,317:
Sure looks like a function in here...
Sure looks like a function in here...</pre>
=={{header|Mastermind}}==
Functions are in-lined at compile time in [[Mastermind]], meaning the "repeat" function cannot accept another procedure as an argument. This is due to limitations of the compilation target, which is [[Brainf***]]. Dynamically calling functions would require creating a function runtime.
<syntaxhighlight lang="mastermind">def do_something<number> {
output "Letter: ";
output 'a' + number;
output '\n';
}
def repeat<times> {
let i = 0;
drain times into i {
do_something<i>;
}
}
let repetitions = 8;
repeat<repetitions>;</syntaxhighlight>
{{out}}
<pre>Letter: a
Letter: b
Letter: c
Letter: d
Letter: e
Letter: f
Letter: g
Letter: h
</pre>
=={{header|Mathematica}}/{{header|Wolfram Language}}==
|