SketchyLISP Reference |
Copyright (C) 2007 Nils M Holm |
<<[remv] | [Index] | [reverse]>> |
Conformance: SketchyLISP Extension
Purpose: Replace data in forms. Replace for each occurence of old in form with new.
Arguments:
OLD - form to replace
NEW - form to insert
FORM - form to process
Implementation:
(define (replace old new form) (cond ((equal? form old) new) ((pair? form) (cons (replace old new (car form)) (replace old new (cdr form)))) (else form)))
Example:
(replace 'f 'g '(lambda (f x) (f x))) => (lambda (g x) (g x))
See also:
substitute.
<<[remv] | [Index] | [reverse]>> |