尝试在方案中创建一个名为map-odd-mapper的过程
我正在尝试制作一个名为 map-odd-mapper 的过程,其中我采用一个过程,然后可以将其应用于列表
ex:
((make-odd-mapper add-one) (list 14 38 29 10 57))
(15 30 58)
我正在考虑将其作为 let 函数,如下所示 (定义(make-odd-mapper f) (让(......使用 ret-odds 的东西来允许索引,以便您可以获得奇数......
ret-odds 定义为 (定义(ret-赔率 lst) (if (null?lst) null (cons (car lst) (if (null? (cdr lst)) null (ret-odds (cdr (cdr lst))))))) 这样做的目的只是为了制作一个过程,它允许我应用诸如将奇数索引列表加一之类的过程......
I'm trying to make a procedure called map-odd-mapper where I take a proc that can then be applied to a list
ex:
((make-odd-mapper add-one) (list 14 38 29 10 57))
(15 30 58)
I was thinking of putting it as a let function as in
(define (make-odd-mapper f)
(let (..........something using ret-odds to allow for the indices so that you can get the odd numbers....
ret-odds is defined as
(define (ret-odds lst)
(if (null? lst) null
(cons (car lst) (if (null? (cdr lst)) null (ret-odds (cdr (cdr lst))))))) the point of this is just to make a proc which will allow me to apply a procedure such as add-one to a list of odd indices....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这个问题可以分解为两个较小的问题。冒着迂腐的风险:你能描述一下这两个较小的问题是什么,并为它们提供测试用例吗?
This problem can be broken down into two smaller ones. At the risk of being pedantic: can you describe what these two smaller problems would be, and provide test cases for them?
(定义(make-odd-mapper f)
(lambda (lst) (ret-odds (map f lst))))
(define (make-odd-mapper f)
(lambda (lst) (ret-odds (map f lst))))