Find whether element in list integer?

scheme

Solution

  (define get-integers
    (lambda (x)
     (if (null? x)
        "All elements of list are integers"
        (if (integer? (car x))
            (get-integers (cdr x))
            "Not all elements are an integer"))))

Problem

I was wondering, how do you check if every element in a list is an integer or not? I can check the first element by using (integer? (car list), but if I do (integer? (cdr list), it always returns false (#f) because the whole of the last part of the list is not an integer as a group. In this case let's say list is defined as. (define list '(1 2 5 4 5 3))

Original source