Skip to content

Instantly share code, notes, and snippets.

@swuecho
Created August 2, 2012 01:31
Show Gist options
  • Select an option

  • Save swuecho/3232300 to your computer and use it in GitHub Desktop.

Select an option

Save swuecho/3232300 to your computer and use it in GitHub Desktop.
functional perl result
sub successor($k){
$k+1;
}
sub natural($k) {
$k;
}
sub pi($k) {
8/($k*($k+2));
}
sub cube($k) {
$k**3;
}
sub pi_succ($k) {
$k+4;
}
say sum_natural(1000);
say sum(1000,&natural,&successor);
say sum_cube(10);
say sum(10,&cube,&successor);
say sum_pi(2e3);
say sum(2e3,&pi,&pi_succ);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment