import Control.Arrow (arr, (&&&)) faroShuffle :: [a] -> [a] faroShuffle a = let d = length a `div` 2 in concat $ uncurry (zipWith (\a b -> [a, b])) $ (arr (take d)) &&& (arr (drop d)) a
i feel in my bones there's wholly point-free way to do it but can't quite get there right now
I managed to get it point free!
import Control.Arrow (arr, (&&&)) faroShuffle :: [a] -> [a] faroShuffle = concat . uncurry (zipWith (\a b -> [a, b])) . uncurry splitAt . ((arr ((`div`2) . length)) &&& (arr id))
I remember looking for the splitAt function when I was writing my first answer, not sure how I missed it in hoogle.
splitAt
Also, I've never seen Control.Arrow before (I'm pretty new to Haskell). Seems useful.
Control.Arrow
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
i feel in my bones there's wholly point-free way to do it but can't quite get there right now
I managed to get it point free!
I remember looking for the
splitAt
function when I was writing my first answer, not sure how I missed it in hoogle.Also, I've never seen
Control.Arrow
before (I'm pretty new to Haskell). Seems useful.