Permutations: Difference between revisions

→‎{{header|Haskell}}: Applied Ormolu, tidied slightly in terms of second
(→‎{{header|Quackery}}: third time lucky, I hope!)
(→‎{{header|Haskell}}: Applied Ormolu, tidied slightly in terms of second)
Line 4,038:
A serialized version:
{{Trans|Mathematica}}
<lang haskell>permutationsimport ::Data.Bifunctor [a] -> [[a]](second)
 
permutations :: [a] -> [[a]]
permutations =
foldrlet ins (\x acxs ->n ac >>= uncurry (fmap<>) .$ inssecond (x :) <*> (enumFromTosplitAt 0n . lengthxs)) [[]]
in foldr
where
ins( \x xsa n =->
let ( a, b) >>= splitAt(fmap n. xsins x)
in a ++ x :<*> b(enumFromTo 0 . length)
)
[[]]
 
main :: IO ()
9,659

edits