Skip to content

Instantly share code, notes, and snippets.

@shubhamkumar13
Created November 13, 2020 04:41
Show Gist options
  • Save shubhamkumar13/24cafe2731f8a14e71c17d86a8d1325a to your computer and use it in GitHub Desktop.
Save shubhamkumar13/24cafe2731f8a14e71c17d86a8d1325a to your computer and use it in GitHub Desktop.
corrections in algorithms design in haskell
inserts :: a -> [a] -> [[a]]
inserts x [] = [[x]]
inserts x (y:ys) = (x:y:ys) : map (y:) (inserts x ys)

perms1 [] = [[]]
perms1 (x:[]) = [[x]]
perms1 (x:xs) = [zs | ys <- perms1 xs, zs <- inserts x ys]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment