Guided Practice 5.3: S-expressions
Design the following functions:
;; characters-in-sexp : Sexp -> Number ;; characters-in-sexps : SexpList -> Number ;; RETURNS: the total number of characters in the strings in the given ;; Sexp or SexpList ;; EXAMPLE/TEST: (begin-for-test (check-equal? (characters-in-sexp (list "alice" (list (list "alice" "bob") "carole") "dave")) 23) ;; subst : Sexp String String -> Sexp ;; GIVEN: a Sexp and two strings, old and new ;; RETURNS: an Sexp just like the given one, except that ;; all instances of old are changed to new. ;; EXAMPLE/TEST: (begin-for-test (check-equal? (subst (list "alice" (list (list "alice" "bob") "dave") "eve" "bob") "bob" "ted") (list "alice" (list (list "alice" "ted") "dave") "eve" "ted")))
Last modified: Fri Aug 11 15:04:33 Eastern Daylight Time 2017