replace-first   scheme


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/runtime/scheme.xtm

Implementation

(define replace-first
   (lambda (obj-a obj-b  lst)
      (if (member obj-a lst)
    (let loop ((new '())
         (lstb lst))
       (if (equal? (car lstb) obj-a)
     (append new (list obj-b) (cdr lstb))
     (loop (append new (list (car lstb))) (cdr lstb))))
    lst)))


Back to Index