Skip to content

Instantly share code, notes, and snippets.

@aya-eiya
Created February 21, 2012 08:38
Show Gist options
  • Save aya-eiya/1875172 to your computer and use it in GitHub Desktop.
Save aya-eiya/1875172 to your computer and use it in GitHub Desktop.
指定した文字列の大文字小文字の組み合わせ全パターンのリストを取得する #haskell
module Main where
import Data.List
import Data.Char
main
= print "ABCD"
getAllUpperLowerPattern str = f3
where
f1 = sequence $ replicate (length str) "01"
f2 = map (\(fs,str)->zip fs str) $ zip f1 (replicate (length f1) str)
f3 = nub [a|cs<-f2,a<-[[if f=='0' then toUpper c else toLower c|(f,c)<-cs]]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment