DEV Community

Discussion on: The easiest problem you cannot solve.

Collapse
 
kspeakman profile image
Kasey Speakman • Edited

In FP, there is a fairly common operation for this called flip. Here is a solution I tested in Chrome console.

const flip = f => a => b => f(b)(a)
flip(K)(cat)(dog)
// "dog"
Collapse
 
joelnet profile image
JavaScript Joel

I did not consider this as a possible solution!

GIF of Simon Cowell exclaiming "Brilliant"