Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DrRacket: atom? and symbol? undefined - What's wrong?

I'm learning programming in Lisp using DrRacket. I don't like it too much but I would like to pass my exam ;)

I have a weird problem - I can't use the atom? and symbol? functions. But number? and string? both work fine.

> (atom? '())
. . atom?: undefined;
 cannot reference an identifier before its definition
> (symbol? A)
. . A: undefined;
 cannot reference an identifier before its definition
> 

Am I doing something wrong? If not, what's the problem?

I'm using DrRacket 6.0.1 on Mac.

like image 307
wiwo Avatar asked Jun 11 '14 22:06

wiwo


1 Answers

For the first error: you have to explicitly define atom?, because in plain Racket is not a built-in procedure (maybe it's in one of the teaching languages):

(define (atom? x)
  (and (not (null? x))
       (not (pair? x))))

Regarding the second error: symbol? is defined, the error is stating that A is undefined. Perhaps you meant this (notice the quote):

(symbol? 'A)
=> #t
like image 85
Óscar López Avatar answered Nov 03 '22 06:11

Óscar López