Created
December 27, 2012 09:38
-
-
Save akanehara/4386918 to your computer and use it in GitHub Desktop.
漫画「ムーたち」で、ムー夫のママがドアノブの前で動かなくなってしまうシーンを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
module Main (main) where | |
main :: IO () | |
main = do | |
let fingersPermutation = permutation fingers | |
mapM_ (putStrLn . show) fingersPermutation | |
putStrLn $ show $ length fingersPermutation | |
fingers :: [Int] | |
fingers = [1..5] | |
permutation :: Eq a => [a] -> [[a]] | |
permutation fs = go [] fs | |
where | |
go path [] = [reverse path] | |
go path rest = rest >>= \f -> go (f : path) [ x | x <- rest, x /= f] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment