Skip to content

Instantly share code, notes, and snippets.

@grondilu
Created December 19, 2012 18:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grondilu/4339194 to your computer and use it in GitHub Desktop.
Save grondilu/4339194 to your computer and use it in GitHub Desktop.
continued fractions, an other attempt
sub continued-fraction(@a, @b)
{
my &f = { $^x };
gather while True {
take my &g = -> $x { &f(@a.shift + @b.shift / $x) };
&f = &g;
}
}
say continued-fraction((1, 2 xx *).list, (1 xx *).list)[1](Inf);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment