A rookie Racket question. I’m using Krishnamurthi’s PLAI textbook for this one, and the associated Racket programming language.
Now, let’s say that I have a defined type as such:
(define-type Thingy
[thingy (num number?)])
So, is there any circumstance at all under which I could get this thingy to accept an empty list '() ?
An empty list is not a number, so the type definition you have will not accept it.
You can use
(lambda (x) (or (number? x) (null? x)))instead ofnumber?to accept either a number or an empty list, but I have no idea why you would want to do that.