Skip to content

Instantly share code, notes, and snippets.

@mernen
Created November 29, 2008 06:28
Show Gist options
  • Select an option

  • Save mernen/30200 to your computer and use it in GitHub Desktop.

Select an option

Save mernen/30200 to your computer and use it in GitHub Desktop.
# Feeling Lispy?
number = 1234
(def method_missing m ,s ,*a ,&b
(s.send m ,*a ,&b) end)
# Ruby 1.8.6 w/ ActiveSupport
(puts (reverse (join (collect (in_groups_of (reverse (Array (chars (String number)))) ,3) ,&:join) ,",")))
# Ruby 1.8.7+, no ActiveSupport dependency
(puts (reverse (join (collect (each_slice (reverse (Array (chars (String number)))) ,3) ,&:join) ,",")))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment