Continued fraction: Difference between revisions

Content added Content deleted
(→‎{{header|Perl 6}}: changing indexing)
m (→‎{{header|Perl 6}}: precision about the triangular reduction metaoperator)
Line 713: Line 713:
where <math>f_n(x) = a_n + \frac{b_n}{x}</math>
where <math>f_n(x) = a_n + \frac{b_n}{x}</math>


Perl6 allows us to define a custom composition operator. We can then use it with the reduction metaoperator, and finally we can call the resulting function with a infinite value for x.
Perl6 allows us to define a custom composition operator. We can then use it with the triangular reduction metaoperator, and finally we can call the resulting function with a infinite value for x.


<lang Perl 6>sub infix:<⚬>(&f, &g) { -> $x { &f(&g($x)) } }
<lang Perl 6>sub infix:<⚬>(&f, &g) { -> $x { &f(&g($x)) } }