문제

I have a procedure like

(lambda (r) (change table r))

I want to use that in an if structure. My main goal is apply a procedure to list elements which satisfy another procedure. I can't use filter because I want to see also unchanged element of list

도움이 되었습니까?

해결책

(define (map-if mapper pred lst)
  (map (lambda (x)
         (if (pred x)
             (mapper x)
             x))
       lst))
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top