6 kyu

Combinator Flip

3,616 of 3,650JTipp

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 Trained4608
Total Skips241
Total Code Submissions11037
Total Times Completed3650
JavaScript Completions3616
CoffeeScript Completions54
Total Stars33
% of votes with a positive feedback rating90% of 168
Total "Very Satisfied" Votes142
Total "Somewhat Satisfied" Votes20
Total "Not Satisfied" Votes6
Ad
Contributors
  • JTipp Avatar
  • jhoffner Avatar
  • leakymirror Avatar
Ad