Welcome to the Functional Programming Zulip Chat Archive. You can join the chat here.
Hi, Is there a webpage or gist or whatever listing the "best" (or worse ? depending of the pov) Haskell one liner functions that are so much concise that no ones understand them ?
not because of badly written code, just an instance of combining too much functions or operators
here's one I like
import Control.Applicative (ZipList(..)) transpose :: [[a]] -> [[a]] transpose = getZipList . traverse ZipList
just take any haskell code and paste it in http://pointfree.io/
?
One classic is this definition of the "powerset" function:
powerset :: [a] -> [[a]] powerset = filterM (const [True,False])
dup :: a -> (a,a) dup = join (,)
variations :: Int -> [a] -> [[a]] variations = replicateM
would be nice if you could include an explanation with your examples
variations?
variations
ah like combinatorial variations?
Good old catamorphism:
newtype Fix f = Fix { unFix :: f (Fix f) } cata :: Functor f => (f a -> a) -> Fix f -> a cata alg = alg . fmap (cata alg) . unFix
sum = foldl' (+) 0
Hi,
Is there a webpage or gist or whatever listing the "best" (or worse ? depending of the pov) Haskell one liner functions that are so much concise that no ones understand them ?
not because of badly written code, just an instance of combining too much functions or operators
here's one I like
just take any haskell code and paste it in http://pointfree.io/
?
One classic is this definition of the "powerset" function:
would be nice if you could include an explanation with your examples
variations
?ah like combinatorial variations?
Good old catamorphism: