Skip to content

Instantly share code, notes, and snippets.

@rebekah
Last active April 23, 2025 08:20
Show Gist options
  • Save rebekah/8d392f49f6c36f8e562e52e42fe9fe48 to your computer and use it in GitHub Desktop.
Save rebekah/8d392f49f6c36f8e562e52e42fe9fe48 to your computer and use it in GitHub Desktop.
question8
(define (substitute s old new)
(define (helper val)
(define (final-val val old-val new-val)
(if (eq? val old-val)
new-val
val
)
)
(if (list? val)
(map helper val)
(final-val val old new)
)
)
(map helper s)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment