LoginSignup
0
0

More than 5 years have passed since last update.

順列列挙(Haskell)

Last updated at Posted at 2013-04-09

車輪の再発明

perm.hs
module Perm whereperm :: Eq a => [a] -> [[a]]perm [] = [[]]perm xs = flatten [  map (y:) rest  | y <- xs, let rest = perm $ filter (/=y) xs ] where flatten :: [[a]] -> [a] flatten xs = foldl (++) [] xs``````bash*Perm> perm "abc"
["abc","acb","bac","bca","cab","cba"]
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0