; Misc handy library functions (many based on Haskell and ML) ; Copyright 2005 Brian Alliet ; delete the first element from a list which is equal? to x ; FEATURE: Use an accumulator (define (delete y xs) (match xs ('() '()) ((cons x xs) (if (equal? x y) xs (cons x (delete y xs)))) )) ; replace replaces the first element of a list equal? to old with new ; FEATURE: Use an accumulator (define (replace old new xs) (match xs ('() '()) ((cons x xs) (if (equal? old x) (cons new xs) (cons x (replace old new xs)))) ))