diff options
Diffstat (limited to 'src/boot/strap/utility.clisp')
-rw-r--r-- | src/boot/strap/utility.clisp | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/boot/strap/utility.clisp b/src/boot/strap/utility.clisp index 5e6003fc..4f9a741f 100644 --- a/src/boot/strap/utility.clisp +++ b/src/boot/strap/utility.clisp @@ -7,7 +7,8 @@ (EXPORT '(|objectMember?| |symbolMember?| |stringMember?| |charMember?| |scalarMember?| |listMember?| |reverse| |reverse!| - |lastNode| |append!| |copyList|)) + |lastNode| |append!| |copyList| |substitute| + |substitute!|)) (DEFUN |objectMember?| (|x| |l|) (LOOP @@ -119,3 +120,25 @@ ((NULL |y|) |x|) (T (RPLACD (|lastNode| |x|) |y|) |x|))) +(DEFUN |substitute!| (|y| |x| |s|) + (COND + ((NULL |s|) NIL) + ((EQ |x| |s|) |y|) + (T (COND + ((CONSP |s|) (RPLACA |s| (|substitute!| |y| |x| (CAR |s|))) + (RPLACD |s| (|substitute!| |y| |x| (CDR |s|))))) + |s|))) + +(DEFUN |substitute| (|y| |x| |s|) + (PROG (|t| |h|) + (RETURN + (COND + ((NULL |s|) NIL) + ((EQ |x| |s|) |y|) + ((CONSP |s|) (SETQ |h| (|substitute| |y| |x| (CAR |s|))) + (SETQ |t| (|substitute| |y| |x| (CDR |s|))) + (COND + ((AND (EQ |h| (CAR |s|)) (EQ |t| (CDR |s|))) |s|) + (T (CONS |h| |t|)))) + (T |s|))))) + |