gpt4 book ai didi

用于转换的 Haskell 标准库函数

转载 作者:行者123 更新时间:2023-12-02 13:33:08 25 4
gpt4 key购买 nike

Haskell 有 Data.List.permutations

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

是否有用于转换的标准库函数,或者您需要自己构建吗?

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

Ruby 的方式是:

 x.repeated_permutation(x.length)

最佳答案

您正在寻找replicateMControl.Monad模块:

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

Live demo

据我所知,它们是字母表中重复的排列['a', 'b']

关于用于转换的 Haskell 标准库函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25230938/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com