Skip to content

Instantly share code, notes, and snippets.

@bgmarx
Created April 17, 2015 20:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bgmarx/9e23f8d651782fcd9226 to your computer and use it in GitHub Desktop.
Save bgmarx/9e23f8d651782fcd9226 to your computer and use it in GitHub Desktop.
def map
[].tap { |out| each { |e| out << yield(e) } }
end
def select
[].tap { |out| each { |e| out << if e yield(e) } }
end
def sort_by
map { |a| [yield(a), a] }.sort.map { |a| a[1] }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment