|
SketchyLISP Reference |
Copyright (C) 2007 Nils M Holm |
| <<[string>=?] | [Index] | [substring]>> |
Conformance: SketchyLISP Extension
Purpose: Substitute variables in forms.
Arguments:
X - form to process
A - association list
Implementation:
(define (substitute x a)
(let ((v (assoc x a)))
(cond (v (cdr v))
((pair? x)
(cons (substitute (car x) a)
(substitute (cdr x) a)))
(else x))))
Example:
(substitute '(i + ii - iii) '((i . 1) (ii . 2) (iii . 3))) => (1 + 2 - 3)
See also:
replace.
| <<[string>=?] | [Index] | [substring]>> |