I'm beginner in SICP. I'm reading section 2.2.4, A Picture Language. I'm stuck with it's example. I didn't understand, How to run these examples?
As given in book, wave is supposed to be a primitive procedure. But When I tried to execute it, REPL throw an error as given below
1 ]=> wave
;Unbound variable: wave
Similarly when I tried to execute first example of this section, REPL throw an error
1 ]=> (define wave2 (beside wave (flip-vert wave)))
;Unbound variable: wave
I didn't understand, what's going wrong? Any help would be appreciated. Thanks.
In DrRacket IDE there is a SICP compatibility language. Using DrRacket helps format code, identify errors and it has a debugger. It also supports standard Scheme as well as it's own dialect, racket, which is very similar but has lots of libraries like most modern languages.
To install (after you have installed DrRacket)
From terminal run:
raco pkg install sicp
You get lots of output and perhaps some WARNINGS. Restart DrRacket and replace #lang racket
with #lang sicp
. To get the picture language add (#%require sicp-pict)
, thus this example should work nicely:
#lang sicp
(#%require sicp-pict)
(paint-hires (below (beside diagonal-shading
(rotate90 diagonal-shading))
(beside (rotate270 diagonal-shading)
(rotate180 diagonal-shading))))
This is a short version of an answer to Which lang packet is proper for SICP in Dr.Racket?