re: The easiest problem you cannot solve. VIEW POST


Some I didn't see

eval(K.toString().replace('b', 'a'))(cat)(dog)
K(...[cat, dog].reverse())()
K(cat => dog)()()
const S = x => y => z => (x(z))(y(z))
S(K)(() => cat)(dog)
S(K)(() => {})(cat => dog)()

K reminded me of SKI calculus and since K technically corresponds to true I went looking for false and saw the wikipedia article actually implements false with the help of the S combinator. One minor issue is that since javascript is not lazily evaluated the second argument has to be a suspended computation for things to work.


Awesome work!

You found the clue I left, the K combinator! And it does come from the SKI calculus.

So many interesting solutions!

eval(K.toString().replace('b', 'a'))(cat)(dog)

This one is pretty creative. Modifying the original K function to swap a and b. I like it.


In hindsight I should have realized that turning the function into a => a => a looks suspiciously like the I combinator.

Exactly! That is definitely the I combinator. It works beautifuly with the K combinator in the problem to solve this problem.

Two parts of SKI combinator calculus!

code of conduct - report abuse