CSE 341 - Scheme Style Guidelines
(cons x xs)and not
(append (list x) xs)
(define (bad-deep-tag-num lst) ;;;(print "Jed & Eric are the coolest thing since string cheese")(newline)(cond ((null? lst) lst) ((number? (car lst)) (append (list (list 'number (car lst)))(bad-deep-tag-num (cdr lst)))) ((list? (car lst)) (append (list (bad-deep-tag-num (car lst))) (bad-deep-tag-num (cdr lst))))((not (list? (car lst))) (append (list (car lst)) (bad-deep-tag-num (cdr lst))))))Better:
;; This procedure will take a list, find the numeric atoms within it ;; or any one of its sublists (recursively) and tag it by placing the ;; numeric atom inside of a list with a key word. (e.g. (number 20)) (define (good-deep-tag-num lst) (display "Jed & Eric are the coolest thing since string cheese") (newline) (cond ((null? lst) ()) ((number? (car lst)) (cons (list 'number (car lst)) (good-deep-tag-num (cdr lst))) ) ((list? (car lst)) (cons (good-deep-tag-num (car lst)) (good-deep-tag-num (cdr lst))) ) (#t (cons (car lst) (good-deep-tag-num (cdr lst)))) ) )