Created
November 27, 2012 12:06
-
-
Save razielgn/4153909 to your computer and use it in GitHub Desktop.
Partially applied lambdas in ruby
This file contains 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
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