Created
April 10, 2011 11:04
-
-
Save chestergrant/912252 to your computer and use it in GitHub Desktop.
Word Descrambler - Haskell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- "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