Created
August 15, 2013 18:48
-
-
Save aamedina/6243580 to your computer and use it in GitHub Desktop.
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
| ;; sometimes it's useful to cache results of previous computations so you don't have to repeat them again | |
| (def sum (memo #(reduce + (range %))) | |
| ;; where the input to sum is the limit of the range of the numbers you want to sum | |
| (time (sum 100000)) | |
| "Elapsed time: 44.191 msecs" | |
| 4999950000 | |
| ;; again? | |
| (time (sum 100000)) | |
| "Elapsed time: 0.417 msecs" | |
| 4999950000 | |
| ;; kthx computer science | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment