3 ms·
I thought it would be fun to write "perm" in Haskell using the List Monad, which is sometimes referred to as expressing nondeterminism. import Data.Foldabl
by lalaithion 7y ago
I thought it would be fun to write "perm" in Haskell using the List Monad, which is sometimes referred to as expressing nondeterminism.
import Data.Foldable (foldrM)
insert x [] = return [x]
insert x (y:ys) = do
z <- insert x ys
[x:y:ys, y:z]
perm = foldrM insert []