関数型プログラミング言語Haskell Part28 [転載禁止]©5ch.io
レス数が950を超えています。1000を超えると書き込みができなくなります。
0985デフォルトの名無しさん
2017/01/14(土) 08:37:41.01ID:z+PGQfymcomb :: String -> Int -> [String]
comb xs = comb' ((group . sort) xs)
where
comb' ys n
| n == 0 = [[]]
| (null . head) ys = comb' (tail ys) n
| (length . concat . tail) ys < n = map ((head . head) ys :) (comb' ((tail . head) ys : tail ys) (n - 1))
| otherwise = map ((head . head) ys :) (comb' ((tail . head) ys : tail ys) (n - 1)) ++ comb' (tail ys) n
こんな感じで組み合わせを求めることはできると思うんだけど速度的には難ありってことなんでしょうか
そのあたりのことを知りたい
レス数が950を超えています。1000を超えると書き込みができなくなります。