Created
November 20, 2013 03:27
-
-
Save nobsun/7557201 to your computer and use it in GitHub Desktop.
ナムドット問題 ref: http://qiita.com/nobsun/items/b3341bb7fea43ff2bba7
This file contains 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
module Main where | |
import Data.List | |
main :: IO () | |
main = putStr | |
$ unlines | |
$ map (intercalate ".") | |
$ map (map reverse) -- 部分文字列反転 | |
$ unravels | |
$ reverse -- 入力文字列反転 | |
$ "12345" | |
unravels :: [a] -> [[[a]]] | |
unravels = foldr (concatMap . uprefixes) [[]] | |
uprefixes :: a -> [[a]] -> [[[a]]] | |
uprefixes x [] = [[[x]]] | |
uprefixes x (xs:xss) = ((x:xs):xss) : map (xs:) (uprefixes x xss) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment