Skip to content

Instantly share code, notes, and snippets.

@razielgn
Created November 27, 2012 12:06
Show Gist options
  • Save razielgn/4153909 to your computer and use it in GitHub Desktop.
Save razielgn/4153909 to your computer and use it in GitHub Desktop.
Partially applied lambdas in ruby
CleanAndCapitalize = ->(s){ s.strip.capitalize }
SplitOn = ->(delim){ ->(s){ s.split(delim).map(&CleanAndCapitalize) } }
SplitAndCleanCsv = SplitOn.(',')
CleanAndCapitalize.('BLA BLU BLI ') # => "Bla blu bli"
SplitAndCleanCsv.('BLA, BLU , BLI ') # => ['Bla', 'Blu', 'Bli']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment