Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

For higher arity there is a combinatorial explosion of all the possible permutations.

But if you want to flip the 2nd and 3rd argument in Haskell it can be done by flip itself:

flip23 foo = (\x -> flip (foo x))



Or just (flip .), which also allows ((flip .) .) etc. for further flips.

In Smullyan's "To Mock a Mockingbird", these combinators are described as "cardinal combinator once/twice/etc. removed", where the cardinal combinator itself defines flip.


I was hoping someone would provide something more succinct ;-). Thanks!




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: