;This function takes a single argument. ;The function returns #t iff the argument is ;a list that contains only atoms. (define atomlist? (lambda (x) (if (or (null? x) (not (list? x) )) #f (atomlist_recurse? x) ) ) ) ;The helper is used because only on ;the original list: ; a null list must be rejected and ; a non-list must be rejected. (define atomlist_recurse? (lambda (x) (cond ((null? x) #t) ((not (atom? (car x))) #f) (else (atomlist_recurse? (cdr x))) ) ) ) ;============== Unit Tests ====================== (load "atom.scm") (load "test.scm") (define msg "atomlist?") (test msg (atomlist? '(1 2 3 4 5)) #t) (test msg (atomlist? '(1)) #t) (test msg (atomlist? '()) #f) (test msg (atomlist? '(1 2 (3 4) 5)) #f) (test msg (atomlist? '((1))) #f)