Variadic fixed-point combinator: Difference between revisions
Content added Content deleted
(Added FreeBASIC) |
(Realize in F#) |
||
Line 61: | Line 61: | ||
</syntaxhighlight> |
</syntaxhighlight> |
||
=={{header|F Sharp|F#}}== |
|||
The following uses [[Y_combinator#March_2024]] |
|||
<syntaxhighlight lang="fsharp"> |
|||
// Variadic fixed-point combinator. Nigel Galloway: March 15th., 2024 |
|||
let h2 n = function 0->2 |g-> n (g-1) |
|||
let h1 n = function 0->1 |g->h2 n (g-1) |
|||
let h0 n = function 0->0 |g->h1 n (g-1) |
|||
let mod3 n=Y h0 n |
|||
[0..10] |> List.iter(mod3>>printf "%d "); printfn "" |
|||
</syntaxhighlight> |
|||
{{output}} |
|||
<pre> |
|||
0 1 2 0 1 2 0 1 2 0 1 |
|||
</pre> |
|||
=={{header|FreeBASIC}}== |
=={{header|FreeBASIC}}== |
||
Unfortunately, due to the limitations of the FreeBASIC language, implementing a variadic fixed-point combinator without explicit recursion is extremely difficult, if not impossible. FreeBASIC does not support higher-order functions in a way that allows this type of metaprogramming. |
Unfortunately, due to the limitations of the FreeBASIC language, implementing a variadic fixed-point combinator without explicit recursion is extremely difficult, if not impossible. FreeBASIC does not support higher-order functions in a way that allows this type of metaprogramming. |