PermUtil.hs
import Data.List permutationsWithLetter x = filter (\letter -> (head letter == x)) . permutations
*Main> :load PermUtil.hs [1 of 1] Compiling Main ( PermUtil.hs, interpreted ) Ok, modules loaded: Main. *Main> *Main> permutationsWithLetter 'a' "abc" ["abc","acb"] *Main> *Main> permutationsWithLetter 'e' "abcde" ["edcba","ecdba","ebcda","ecbda","ebdca","edbca","eabcd","ebacd","ebcad","eacbd","ecabd","ecbad","eadcb","edacb","edcab","eacdb","ecadb","ecdab","eadbc","edabc","edbac","eabdc","ebadc","ebdac"] *Main>
No comments:
Post a Comment