Skip to content

Instantly share code, notes, and snippets.

@chestergrant
Created April 10, 2011 11:04
Show Gist options
  • Save chestergrant/912252 to your computer and use it in GitHub Desktop.
Save chestergrant/912252 to your computer and use it in GitHub Desktop.
Word Descrambler - Haskell
-- "Created by: Chester Grant |Got code from:http://www.haskell.org/pipermail/haskell-cafe/2002-June/003122.html";
-- "Purpose: Unscrambles letters(see line 199)\n";
-- "Date: 9th/04/2011\n";
selections [] = []
selections (x:xs) = (x,xs) : [ (y,x:ys) | (y,ys) <- selections xs ]
permutations :: [a] -> [[a]]
permutations [] = [[]]
permutations xs = [ y : zs | (y,ys) <- selections xs, zs <- permutations ys]
main = print (permutations "eschs")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment