2
votes

I've successfully installed the SICP package for DrRacket; and I tested it by using the inc operator in the GUI. I followed the instructions here.

However, when I run racket in bash, using the inc operator gives me an error.

Welcome to Racket v6.6.

> (inc 42)

inc: undefined; cannot reference undefined identifier context...: /usr/share/racket/collects/racket/private/misc.rkt:88:7

Clearly, I haven't installed it properly. So what do I do?

EDIT 1: Additionally, the 1+ and the -1+ operators give a similar error, for both DrRacket's GUI and racket in bash.

1
inc and 1+ are not standard, you should not use them anyway. Better use add1, which is supported in Racket... - Óscar López
@ÓscarLópez Not if you are interested in the SICP module language. - Sylwester
But as far as i remember, in the 2nd edition of SICP they don't use inc, 1+ - Óscar López
@ÓscarLópez I'm using a reformatted version from here: sicpebook.wordpress.com/ebook. This version uses inc, while in the video lectures of the original course they use 1+. - Nadim Hussami

1 Answers

4
votes

Looks like you forgot to include the sicp collection:

~$ racket -l sicp --repl
Welcome to Racket v6.6.
> (inc 4)
5

You can also just start racket normally and evaluate (require sicp) before doing any SICP stuff:

~$ racket
Welcome to Racket v6.6.
> (require sicp)
> (inc 4)
5