| Introduction to Functional Programming in Scheme - slide 18 : 49 |
(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 this simple kind of (self) reflection.


![Next page: Other Data Types [Section] -- Keyboard shortcut: 'n' Next page: Other Data Types [Section] -- Keyboard shortcut: 'n'](./images/nav-right.gif)




