Repeat: Difference between revisions
Content added Content deleted
(Added various dialects BASIC (BASIC256, QBasic, Chipmunk Basic, GW-BASIC, True BASIC, Minimal BASIC, MSX Basic, Quite BASIC and XBasic)) |
|||
Line 1,256: | Line 1,256: | ||
=={{header|Lean}}== |
=={{header|Lean}}== |
||
===Lean 3.4.2=== |
|||
<syntaxhighlight lang="lean"> |
|||
def repeat : ℕ → (ℕ → string) → string |
|||
| 0 f := "done" |
| 0 f := "done" |
||
| (n + 1) f := (f n) ++ (repeat n f) |
| (n + 1) f := (f n) ++ (repeat n f) |
||
Line 1,265: | Line 1,265: | ||
#eval repeat 5 $ λ b : ℕ , "me " |
#eval repeat 5 $ λ b : ℕ , "me " |
||
</syntaxhighlight> |
</syntaxhighlight> |
||
{{out}} |
|||
<pre> |
|||
"me me me me me done" |
|||
</pre> |
|||
===Lean 4=== |
|||
<syntaxhighlight lang="lean"> |
|||
def repeatf (f : Nat -> String) (n : Nat) : String := |
|||
match n with |
|||
| 0 => "." |
|||
| (k + 1) => (f k) ++ (repeatf f k) |
|||
def example1 : String := |
|||
repeatf (fun (x : Nat) => toString (x) ++ " ") (10) |
|||
#eval example1 |
|||
</syntaxhighlight> |
|||
{{out}} |
|||
<pre> |
|||
"9 8 7 6 5 4 3 2 1 0 ." |
|||
</pre> |
|||
=={{header|LiveCode}}== |
=={{header|LiveCode}}== |