Continued fraction: Difference between revisions

Content added Content deleted
(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
m (Fix Perl6 -> Raku in comments)
Line 2,358: Line 2,358:
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 has a builtin composition operator. We can use it with the triangular reduction metaoperator, and evaluate each resulting function at infinity (any value would do actually, but infinite makes it consistent with this particular task).
Raku has a builtin composition operator. We can use it with the triangular reduction metaoperator, and evaluate each resulting function at infinity (any value would do actually, but infinite makes it consistent with this particular task).
<lang perl6>sub continued-fraction(@a, @b) {
<lang perl6>sub continued-fraction(@a, @b) {
map { .(Inf) }, [\o] map { @a[$_] + @b[$_] / * }, ^Inf
map { .(Inf) }, [\o] map { @a[$_] + @b[$_] / * }, ^Inf