Skip to content

Instantly share code, notes, and snippets.

@colomon
Created July 20, 2010 11:37
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 colomon/482850 to your computer and use it in GitHub Desktop.
Save colomon/482850 to your computer and use it in GitHub Desktop.
sub sine-power($x) {
my $sign = 1;
my $x-part = $x;
my $denom = 1;
gather for 3, 5 ... * -> $n {
take $sign * $x-part / $denom;
$sign *= -1;
$x-part *= $x * $x;
$denom *= $n * ($n - 1);
}
}
say sine-power(0.1).munch(4).perl;
say ([+] sine-power(0.1).munch(3)).perl;
say [+] sine-power(0.1).munch(3);
say sin(0.1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment