8

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.

1
  • DrRacket is an IDE that supports many different and often incompatible languages. You need to know which language to set. Scheme is not one language since we have many incompatible reports and lots of languages that are not completely compatible, like #!racket (one language only supported by DrRacket) Lisp is an even more diverse group as it's everything with parenthesized polish prefix notation. Commented Jun 12, 2014 at 8:52

1 Answer 1

12

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 
Sign up to request clarification or add additional context in comments.

5 Comments

@user3184237 Are your notes about the language Scheme or the language Racket?
We are using DrRacket so I was shure that it was about Scheme
@user3184237 DrRacket supports a number of languages, only one of which is Scheme. Scheme isn't the default language in DrRacket, Racket is. (There's a reason that they renamed it from DrScheme to DrRacket, after all.)
Óscar: what are does teaching languages that you mention in your answer? Thanks.
For example, the language used for teaching How to Design Programs

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.