Created
August 2, 2012 01:22
-
-
Save swuecho/3232254 to your computer and use it in GitHub Desktop.
functional perl result
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sub successor($k){ | |
| $k+1; | |
| } | |
| sub cube($k) { | |
| $k**3; | |
| } | |
| #sub sub_cubf($n){ | |
| # sum($n,successor,cube); | |
| #} | |
| sub natural($k) { | |
| $k; | |
| } | |
| sub pi($k) { | |
| 8/($k*($k+2)); | |
| } | |
| sub pi_term($k) { | |
| $k+4; | |
| } | |
| say sum_natural(1000); | |
| say sum(1000,&natural,&successor); | |
| say sum_pi(2e3); | |
| say sum(2e3,&pi,&pi_term); | |
| say sum_cube(10); | |
| say sum(10,&cube,&successor); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment