Created
October 18, 2012 05:51
-
-
Save honbin/3910091 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
# reference url: http://jp.rubyist.net/magazine/?0038-MapAndCollect#l2 | |
#reduce for lisp | |
# (reduce (lambda (i j) (+ i j)) '(3 4 5 6)) | |
#reduce for ruby | |
p [3, 4, 5, 6].reduce {|i, j| i + j } #=>18 | |
#inject for smalltalk | |
# #(3 4 5 6) inject: 0 into: [:i :j | i + j ] | |
#inject for ruby | |
p [3, 4, 5, 6].inject(0) {|i, j| i + j } #=>18 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment