3 ms·
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 don
by Jaxan 1y ago
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))
- marvinborner 1y agoOr 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.
- Jaxan 1y agoI was hoping someone would provide something more succinct ;-). Thanks!