Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
19
Task/Repeat/Ada/repeat.adb
Normal file
19
Task/Repeat/Ada/repeat.adb
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
with Ada.Text_IO;
|
||||
|
||||
procedure Repeat_Example is
|
||||
|
||||
procedure Repeat(P: access Procedure; Reps: Natural) is
|
||||
begin
|
||||
for I in 1 .. Reps loop
|
||||
P.all; -- P points to a procedure, and P.all actually calls that procedure
|
||||
end loop;
|
||||
end Repeat;
|
||||
|
||||
procedure Hello is
|
||||
begin
|
||||
Ada.Text_IO.Put("Hello! ");
|
||||
end Hello;
|
||||
|
||||
begin
|
||||
Repeat(Hello'Access, 3); -- Hello'Access points to the procedure Hello
|
||||
end Repeat_Example;
|
||||
12
Task/Repeat/Asymptote/repeat.asymptote
Normal file
12
Task/Repeat/Asymptote/repeat.asymptote
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
void proc() {
|
||||
write(" Inside loop");
|
||||
}
|
||||
|
||||
void repeat(void func(), int times) {
|
||||
for (int i = 0; i < times; ++i) {
|
||||
func();
|
||||
}
|
||||
}
|
||||
|
||||
repeat(proc, 5);
|
||||
write("Loop Ended");
|
||||
13
Task/Repeat/Chapel/repeat-1.chpl
Normal file
13
Task/Repeat/Chapel/repeat-1.chpl
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
config const n = 5;
|
||||
|
||||
proc example()
|
||||
{
|
||||
writeln("example");
|
||||
}
|
||||
|
||||
proc repeat(func, n)
|
||||
{
|
||||
for i in 0..#n do func();
|
||||
}
|
||||
|
||||
repeat(example, n);
|
||||
13
Task/Repeat/Chapel/repeat-2.chpl
Normal file
13
Task/Repeat/Chapel/repeat-2.chpl
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
config const n = 5;
|
||||
|
||||
proc example()
|
||||
{
|
||||
writeln("example");
|
||||
}
|
||||
|
||||
proc repeat(func : proc(), n : uint)
|
||||
{
|
||||
for i in 0..#n do func();
|
||||
}
|
||||
|
||||
repeat(example, n);
|
||||
13
Task/Repeat/Chapel/repeat-3.chpl
Normal file
13
Task/Repeat/Chapel/repeat-3.chpl
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
config const n = 5;
|
||||
|
||||
proc example(x : uint)
|
||||
{
|
||||
writeln("example ", x);
|
||||
}
|
||||
|
||||
proc repeat(func : proc(x : uint), n : uint)
|
||||
{
|
||||
for i in 0..#n do func(i);
|
||||
}
|
||||
|
||||
repeat(example, n);
|
||||
7
Task/Repeat/Crystal/repeat.cr
Normal file
7
Task/Repeat/Crystal/repeat.cr
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
4.times{ puts "Example" } # idiomatic way
|
||||
|
||||
def repeat(proc,num)
|
||||
num.times{ proc.call }
|
||||
end
|
||||
|
||||
repeat(->{ puts "Example" }, 4)
|
||||
14
Task/Repeat/Dart/repeat.dart
Normal file
14
Task/Repeat/Dart/repeat.dart
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
void proc() {
|
||||
print(" Inside loop");
|
||||
}
|
||||
|
||||
void repeat(Function func, int times) {
|
||||
for (var i = 0; i < times; i++) {
|
||||
func();
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
repeat(proc, 5);
|
||||
print("Loop Ended");
|
||||
}
|
||||
11
Task/Repeat/Euphoria/repeat.eu
Normal file
11
Task/Repeat/Euphoria/repeat.eu
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
procedure repeat(integer proc, integer times)
|
||||
for i = 1 to times do
|
||||
call_proc(proc, {})
|
||||
end for
|
||||
end procedure
|
||||
|
||||
procedure say_hello()
|
||||
puts(1, "hello\n")
|
||||
end procedure
|
||||
|
||||
repeat(routine_id("say_hello"), 3)
|
||||
15
Task/Repeat/Gleam/repeat.gleam
Normal file
15
Task/Repeat/Gleam/repeat.gleam
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
import gleam/io
|
||||
|
||||
pub fn main() {
|
||||
repeat(3, fn() { io.println("hello") })
|
||||
}
|
||||
|
||||
pub fn repeat(times: Int, func: fn() -> Nil) -> Nil {
|
||||
case times {
|
||||
_ if times < 1 -> Nil
|
||||
_ -> {
|
||||
func()
|
||||
repeat(times - 1, func)
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Task/Repeat/Icon/repeat.icon
Normal file
12
Task/Repeat/Icon/repeat.icon
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
procedure main(A)
|
||||
n := \A[1] | 10
|
||||
runit(P,n) | write()
|
||||
runit(Q,n) | write()
|
||||
end
|
||||
|
||||
procedure runit(p,n)
|
||||
every 1 to n do p()
|
||||
end
|
||||
|
||||
procedure P(); writes("."); end
|
||||
procedure Q(); writes("+"); end
|
||||
11
Task/Repeat/JavaScript/repeat.js
Normal file
11
Task/Repeat/JavaScript/repeat.js
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
function repeat(f, n) {
|
||||
while (n-- > 0) {
|
||||
f();
|
||||
}
|
||||
}
|
||||
|
||||
function test() {
|
||||
console.log("test");
|
||||
}
|
||||
|
||||
repeat(test, 3);
|
||||
15
Task/Repeat/LOLCODE/repeat.lol
Normal file
15
Task/Repeat/LOLCODE/repeat.lol
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
HAI 1.3
|
||||
|
||||
HOW IZ I REPEAT YR DEMANZ AN YR TIMEZ
|
||||
IM IN YR LOOP UPPIN YR VAR TIL BOTH SAEM VAR AN TIMEZ
|
||||
I IZ DEMANZ MKAY
|
||||
IM OUTTA YR LOOP
|
||||
IF U SAY SO
|
||||
|
||||
HOW IZ I SAYHELLO
|
||||
VISIBLE "HELLO"
|
||||
IF U SAY SO
|
||||
|
||||
I IZ REPEAT YR SAYHELLO AN YR 3 MKAY
|
||||
|
||||
KTHXBYE
|
||||
5
Task/Repeat/Maxima/repeat.maxima
Normal file
5
Task/Repeat/Maxima/repeat.maxima
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
repeat(f, n) := thru n do f()$
|
||||
|
||||
test() := print("test")$
|
||||
|
||||
repeat(test, 3);
|
||||
18
Task/Repeat/OxygenBasic/repeat.basic
Normal file
18
Task/Repeat/OxygenBasic/repeat.basic
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
uses console
|
||||
|
||||
sub proc
|
||||
printl " Inside loop"
|
||||
end sub
|
||||
|
||||
macro rep (func, n)
|
||||
int i
|
||||
for i = 1 to n
|
||||
func()
|
||||
next
|
||||
end macro
|
||||
|
||||
rep (proc, 5)
|
||||
printl "Loop Ended"
|
||||
|
||||
printl cr "Enter ..."
|
||||
waitkey
|
||||
|
|
@ -1,13 +1,11 @@
|
|||
-->
|
||||
<span style="color: #008080;">procedure</span> <span style="color: #000000;">Repeat</span><span style="color: #0000FF;">(</span><span style="color: #004080;">integer</span> <span style="color: #000000;">rid</span><span style="color: #0000FF;">,</span> <span style="color: #004080;">integer</span> <span style="color: #000000;">n</span><span style="color: #0000FF;">)</span>
|
||||
<span style="color: #008080;">for</span> <span style="color: #000000;">i</span><span style="color: #0000FF;">=</span><span style="color: #000000;">1</span> <span style="color: #008080;">to</span> <span style="color: #000000;">n</span> <span style="color: #008080;">do</span>
|
||||
<span style="color: #000000;">rid</span><span style="color: #0000FF;">()</span>
|
||||
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
|
||||
<span style="color: #008080;">end</span> <span style="color: #008080;">procedure</span>
|
||||
procedure Repeat(integer rid, integer n)
|
||||
for i=1 to n do
|
||||
rid()
|
||||
end for
|
||||
end procedure
|
||||
|
||||
<span style="color: #008080;">procedure</span> <span style="color: #000000;">Hello</span><span style="color: #0000FF;">()</span>
|
||||
<span style="color: #0000FF;">?</span><span style="color: #008000;">"Hello"</span>
|
||||
<span style="color: #008080;">end</span> <span style="color: #008080;">procedure</span>
|
||||
procedure Hello()
|
||||
?"Hello"
|
||||
end procedure
|
||||
|
||||
<span style="color: #000000;">Repeat</span><span style="color: #0000FF;">(</span><span style="color: #000000;">Hello</span><span style="color: #0000FF;">,</span><span style="color: #000000;">5</span><span style="color: #0000FF;">)</span>
|
||||
<!--
|
||||
Repeat(Hello,5)
|
||||
|
|
|
|||
10
Task/Repeat/Pluto/repeat.pluto
Normal file
10
Task/Repeat/Pluto/repeat.pluto
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
local function f(g, n)
|
||||
for _ = 1, n do g(n) end
|
||||
end
|
||||
|
||||
local function g(k)
|
||||
for i = 1, k do io.write($"{i} ") end
|
||||
print()
|
||||
end
|
||||
|
||||
f(g, 5)
|
||||
14
Task/Repeat/PowerShell/repeat.ps1
Normal file
14
Task/Repeat/PowerShell/repeat.ps1
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
function Out-Example
|
||||
{
|
||||
"Example"
|
||||
}
|
||||
|
||||
function Step-Function ([string]$Function, [int]$Repeat)
|
||||
{
|
||||
for ($i = 1; $i -le $Repeat; $i++)
|
||||
{
|
||||
"$(Invoke-Expression -Command $Function) $i"
|
||||
}
|
||||
}
|
||||
|
||||
Step-Function Out-Example -Repeat 3
|
||||
2
Task/Repeat/Uiua/repeat-1.uiua
Normal file
2
Task/Repeat/Uiua/repeat-1.uiua
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
⍥(&p"Hi") 3 # take repetitions as an argument
|
||||
⍥₃(&p"Hi") # or a subscript, if you know the number ahead of time
|
||||
2
Task/Repeat/Uiua/repeat-2.uiua
Normal file
2
Task/Repeat/Uiua/repeat-2.uiua
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
Repeat! ← ◌⍢⊙^⊃±-₁
|
||||
Repeat!(&p"Hi") 3
|
||||
Loading…
Add table
Add a link
Reference in a new issue