Repeat: Difference between revisions

1,558 bytes added ,  16 days ago
m
Applesoft BASIC - fixed broken link, included code from linked web page
m (Applesoft BASIC - fixed broken link, included code from linked web page)
(4 intermediate revisions by 4 users not shown)
Line 327:
 
=={{header|Applesoft BASIC}}==
https://web.archive.org/web/20190202165511/http://hoop-la.ca/apple2/2016/winterwarmup/#repeat.bas
<syntaxhighlight> 100 FOR I = 768 TO 794
110 READ B: POKE I,B: NEXT
120 DATA165,185,72,165,184,72
130 DATA165,118,72,165,117,72
140 DATA169,176,72,32,123,221
150 DATA32,82,231,32,65,217
160 DATA76,210,215
170 POKE 1014,0: POKE 1015,3
 
200 LET P = 400:N = 4
210 GOSUB 300"REPEAT P N
220 END
 
300 IF N < = 0 THEN RETURN
310 LET N = N - 1
320 & P
330 GOTO 300
 
400 PRINT "EXAMPLE"
410 RETURN
</syntaxhighlight>
 
=={{header|Arturo}}==
Line 1,317 ⟶ 1,338:
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}}==
Line 1,935 ⟶ 1,984:
hello
</pre>
 
=={{header|Refal}}==
<syntaxhighlight lang="refal">$ENTRY Go {
= <Prout <Repeat 3 Example> Eggs And <Example>>;
}
 
Repeat {
0 s.F e.X = e.X;
s.N s.F e.X = <Repeat <- s.N 1> s.F <Mu s.F e.X>>;
};
 
Example {
e.X = e.X Spam;
};</syntaxhighlight>
{{out}}
<pre>Spam Spam Spam Eggs And Spam</pre>
 
=={{header|REXX}}==
Line 1,981 ⟶ 2,046:
 
=={{header|RPL}}==
≪ → func n ≪ 1 n '''START''' func EVAL '''NEXT'''
≪ 1 n '''START''' func EVAL '''NEXT'''
≫ ≫ 'TIMES' STO
≫ ≫ '<span style="color:blue>TIMES</span>' STO
≪ " world" "Hello" SWAP + ≫ 3 <span style="color:blue>TIMES</span>
{{out}}
<pre>
Line 2,363 ⟶ 2,429:
 
=={{header|Wren}}==
<syntaxhighlight lang="ecmascriptwren">var f = Fn.new { |g, n|
for (i in 1..n) g.call(n)
}
413

edits