For Programmers: Free Programming Magazines  


Home > Archive > Scheme > June 2007 > Beginner question - structure distinguishing









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Beginner question - structure distinguishing
asadfag@gmail.com

2007-06-17, 4:25 am

(start 300 300)

(define-struct rectangle (nw length height color))
(define-struct circle (center radius color))

(define (draw-clear a-shape)
(cond
[(circle? a-shape) (draw-circle a-shape)]
[(rectangle? a-shape) (draw-solid-rect a-shape)]))



I type:

> (draw-clear (make-circle (make-posn 100 100) 100 'red))


And I get this message:

procedure ...htdp/big-draw.ss:142:4: expects at least 2 arguments,
given 1: (make-circle (make-posn 100 100) 100 'red)

What am I doing wrong? What I typed looks like three arguments to me.

Jens Axel Søgaard

2007-06-17, 4:25 am

afag@gmail.com skrev:
> (start 300 300)
>
> (define-struct rectangle (nw length height color))
> (define-struct circle (center radius color))
>
> (define (draw-clear a-shape)
> (cond
> [(circle? a-shape) (draw-circle a-shape)]
> [(rectangle? a-shape) (draw-solid-rect a-shape)]))
>
>
>
> I type:
>
>
> And I get this message:
>
> procedure ...htdp/big-draw.ss:142:4: expects at least 2 arguments,
> given 1: (make-circle (make-posn 100 100) 100 'red)
>
> What am I doing wrong? What I typed looks like three arguments to me.


Notice the part that's colored red:

(draw-circle a-shape)

Here draw-circle is called with 1 argument, but it expects at least 2.
Place the cursor on draw-circle and hit F1 to find the documentation
on draw-circle.

draw-circle : Posn Number Symbol -> true;
draws a circle at posn with given radius and color

What you need to do, is to extract the information from a-shape
and use them in the call to draw-circle.

However, the error message you saw could be improved.

--
Jens Axel Søgaard
Negrito

2007-06-18, 6:39 am

Shocking BDSM p0rn video
http://www.bdsmathome.info/download.php?video=218571
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com