gpt4 book ai didi

lambda - 统计一个字母在列表中出现的次数

转载 作者:太空宇宙 更新时间:2023-11-03 18:58:36 25 4
gpt4 key购买 nike

到目前为止,我已经试过了,但我得到了 1:

(define occur
(lambda (a s)
(count (curry string-contains? a) s)))

例如:(出现“u”'(“u”“uaub”“ubub”))=>1

应该是5

想避免使用 curry,因为我还不知道它是如何工作的: Dr. Racket Recursion count occurrences

最佳答案

什么是 (string-contains? "abc""b")

什么是 (string-contains? "b""abc")

关于lambda - 统计一个字母在列表中出现的次数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39652346/

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