سؤال

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