6 kyu

Combinator Flip

3,393 of 3,427JTipp

Description:

Create a combinator function named flip that takes a function as an argument and returns that function with it's arguments reversed.

For example:

flip(print)(4,5) // returns "5 -> 4"
function print(a,b) {
  return a + " -> " + b;
}
file(print)(4,5) # return '5 -> 4'
print = (a,b) ->
  a + ' -> ' + b

The idea is to reverse any number of arguments using a higher order function, without any concern for the function being passed into it.

Functional Programming
Fundamentals

Stats:

CreatedSep 18, 2014
PublishedSep 18, 2014
Warriors Trained4371
Total Skips241
Total Code Submissions10701
Total Times Completed3427
JavaScript Completions3393
CoffeeScript Completions54
Total Stars33
% of votes with a positive feedback rating91% of 164
Total "Very Satisfied" Votes139
Total "Somewhat Satisfied" Votes19
Total "Not Satisfied" Votes6
Ad
Contributors
  • JTipp Avatar
  • jhoffner Avatar
  • leakymirror Avatar
Ad