Code doesn't work, not surprised however it's yet another example from a book

Things were was executing ok until I added section that I have marked which was supposed to plot the the set union. I was very suspicious of the code that as the offending terms were never defined. Any thoughts on what it should be? And a general question, what is the significance when some identifiers are all in capitol letters, other than the obvious of differentiating it from, a keyword of same name. Is there something more too that?
I know it's a lo of questions however, I've searched through the online docs a my small library of books on Racket. Too either the answers are in there or I've finally slipped over the edge and ready to. be moved to Shady Pines Elder Estate! :rofl:

Cheers,
Munroe

The Code:

#lang racket   ;set theory 2   PTFW pp 97 thru top of pp 100
(require racket/draw)
(define WIDTH 150)
(define HEIGHT 100)

(define venn (make-bitmap WIDTH HEIGHT))
(define  dc (new bitmap-dc% [bitmap  venn]))

(send dc scale 1.0 -1.0)
(send dc translate (/ WIDTH 2) (/ HEIGHT -2))
(send dc set-smoothing 'smoothed)
(send dc set-pen "black" 2 'solid)

(define IN-BRUSH (new brush% [color "green"]))
(define OUT-BRUSH (new brush% [ color (make-object color% 220 220 220)]))

(define (rect x y w h b)
  (let ([x (- x (/ w 2))]
        [y (- y (/ h 2))])
    (send dc set-brush b)
    (send dc draw-rectangle x y w h)))

(define (circle x y r b)
  (let ([x (- x r)]
        [y (- y r)])

    (send dc set-brush b)
    (send dc draw-ellipse x y (* 2 r) (* 2 r))))

(define (universe b) (rect 0 0 (- WIDTH 10) (- HEIGHT 10) b))

(universe OUT-BRUSH)
(circle 0 0 30 IN-BRUSH)
venn

(send dc erase)
(universe IN-BRUSH)
(circle 0 0 30 OUT-BRUSH)
venn

(define (piscis x y r b)
  (let* ([y (- y r)]
         [2r (* 2 r)]
         [y1 (sqrt (- (sqr r) (sqr x)))] ;y-intercept
         [π pi]
         [ø (asin  (/ y1 r))]
         [𝜭 (- π ø)]
         [path (new  dc-path%)])
    (send dc set-brush b)
    (send path move-to 0 (- y1))
    (send path arc (- x r)   y 2r 2r 𝜭  (+ π ø))
    (send path arc (- (- x) r)   y 2r 2r (- ø) ø)
    (send dc draw-path path)))

(define SET-BRUSH (new brush% [color (make-object color% 220 255 250)]))

(define(venn-bin b1 b2 b3)
  (universe OUT-BRUSH)

;Racket obviously complains that "CIRCLE-OFF is an unbound entity. I    ;considering typos such as the offending term should  be lower case. But more ;troubling I have no clue what that general form is trying to accomplish? 
*****(circle (- CIRCLE-OFF) 0 30 b1)
*****(circle  CIRCLE-OFF 0 30 b3)
*****(piscis  CIRCLE-OFF 0 30 b2)
  (print venn))

(venn-bin IN-BRUSH IN-BRUSH IN-BRUSH)
1 Like

Add (define CIRCLE-OFF 20) to the code.

(Uppercase identifiers are conventionally used as names for constants)

1 Like

For those wanting to learn Scheme/Racket from scratch here is a cool course:

unfortunately in "Français" only :sweat_smile:

1 Like

Hi Rodger,

Thank you for the very prompt reply to my newbie question.

Well that certainly fixed the problem however, why? I understand defining CIRCLE-OFF but why "20” ?? As an aside, I’m constantly frustrated by the errors and/or omissions in all of the texts on Racket currently in my library. I would dearly love to purchase a tutorial text that wasn’t plagued with issues like, this and whilst I’m whining , most of them lack an index so the inclusion of that would be a huge plus.

Cheers,

M.C. “Moe” Clayton

“Old age ain't no place for sissies.”

― Bette Davis

Sent from

Canary Mail
You've received a secure email

Munroe Clayton has sent you a secure email via Canary Mail.

Read Secure Email

If you expect to correspond often with Munroe Clayton, we recommend you download Canary Mail for free.

Download Canary

Twitter

Website

Privacy | Terms | Docs | Support

Copyright © 2021 Canary Mail, All rights reserved.

1 Like

Canary Mail
You've received a secure email

Munroe Clayton has sent you a secure email via Canary Mail.

Read Secure Email

If you expect to correspond often with Munroe Clayton, we recommend you download Canary Mail for free.

Download Canary

Twitter

Website

Privacy | Terms | Docs | Support

Copyright © 2021 Canary Mail, All rights reserved.