Created
August 2, 2012 01:31
-
-
Save swuecho/3232300 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 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