znfnjw
Last Updated: February 25, 2016
·
963
· rsslldnphy
Photo

The Haskell equivalent of Clojure's "juxt" is "sequence".

It took me a while to find this - I was sure it would be possible but couldn't work it out. To apply a list of functions to an argument, generating a list of the results:

-- Clojure
((juxt inc dec (partial * 3)) 4) ; => [5 3 12]

-- Haskell
sequence [succ, pred, (*3)] 4 -- [5, 3, 12]
Say Thanks
Respond