Haskell标准库函数用于转换

时间:2014-08-10 16:55:16

标签: haskell

Haskell有Data.List.permutations

permutations "abc" == ["abc","bac","cba","bca","cab","acb"]

是否有用于转换的标准库函数,还是需要自己编写?

transformations "ab" == ["aa","ab","ba","bb"]

Ruby方式是:

 x.repeated_permutation(x.length)

1 个答案:

答案 0 :(得分:5)

您正在寻找replicateM模块中的Control.Monad

replicateM 2 "ab"
-- ["aa","ab","ba","bb"]

Live demo

AFAIK,它们是字母['a', 'b']重复的排列。