(define (as-number x) (cond ((string? x) (string->number x)) ((number? x) x) ((char? x) (char->integer x)) ((boolean? x) (if x 1 0)) ; false -> 0, true -> 1 (else (error (string-append "Cannot convert to number " (as-string x))))
But in other Lisp systems there is easy access to self reflection