Skip to content

Instantly share code, notes, and snippets.

@nobsun
Created November 20, 2013 03:27
Show Gist options
  • Save nobsun/7557201 to your computer and use it in GitHub Desktop.
Save nobsun/7557201 to your computer and use it in GitHub Desktop.
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