Trying to make a procedure called map-odd-mapper i

2019-08-23 15:21发布

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....

2条回答
疯言疯语
2楼-- · 2019-08-23 15:44

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?

查看更多
放我归山
3楼-- · 2019-08-23 15:45

(define (make-odd-mapper f) (lambda (lst) (ret-odds (map f lst))))

查看更多
登录 后发表回答