Skip to content

Instantly share code, notes, and snippets.

@honbin
Created October 18, 2012 05:46
Show Gist options
  • Select an option

  • Save honbin/3910082 to your computer and use it in GitHub Desktop.

Select an option

Save honbin/3910082 to your computer and use it in GitHub Desktop.
# reference url: http://jp.rubyist.net/magazine/?0038-MapAndCollect#l2
# map for lisp
# (map 'list (lambda (i) (+ i 1)) '(3 4 5 6))
#map for ruby
p [3, 4, 5, 6].map {|i| i + 1 } #=>[4, 5, 6, 7]
#collect for smalltalk
# #(3 4 5 6) collect: [:i | i + 1 ]
#collect for ruby
p [3, 4, 5, 6].collect {|i| i + 1 } #=>[4, 5, 6, 7]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment