Am I missing something??
> (define-struct status (a d))
> (define T (triangle 10 "outline" "black"))
> (define TT (triangle 10 "solid" "black"))
> (define (draw s) (rotate (* 120 (status-a s)) (above T (beside T TT))))
> (draw (make-status (0 1)))
function call: expected a function after the open parenthesis, but found a number
> (make-status (0 1))
function call: expected a function after the open parenthesis, but found a number
It seems like Dr. Racket is asking for a function for d. I also had this question while trying to answer it by hand, so I thought Racket could help. I'll bring it to office hours on Monday.
I'm also finding this question tricky!! But I'm on the right track so far.
> (define (c n) (circle n "outline" "black"))
> (c 10)
.
> (repeated (c (range 10 55 10)) 5)
circle: expects a non negative real number as first argument, given (list 10 20 30 40 50)
> (define circles (map c (range 10 55 10)))
> (define circles2 c (map c (range 10 55 10)))
define: expected only one expression after the variable name circles2, but found 1 extra part
> (circles (map 10))
map: arity mismatch;
the expected number of arguments does not match the given number
given: 1
arguments...:
10
> (circles (map 10 (range 10 55 10)))
map: expects a procedure as 1st argument, given 10
> (circles (map c (range 10 55 10)))
function call: expected a function after the open parenthesis, but received (list #<image> #<image> #<image> #<image> #<image>)
> (c 10)
.
> (repeated (c (range 10 55 10)) 5)
circle: expects a non negative real number as first argument, given (list 10 20 30 40 50)
> (define circles (map c (range 10 55 10)))
> (define circles2 c (map c (range 10 55 10)))
define: expected only one expression after the variable name circles2, but found 1 extra part
> (circles (map 10))
map: arity mismatch;
the expected number of arguments does not match the given number
given: 1
arguments...:
10
> (circles (map 10 (range 10 55 10)))
map: expects a procedure as 1st argument, given 10
> (circles (map c (range 10 55 10)))
function call: expected a function after the open parenthesis, but received (list #<image> #<image> #<image> #<image> #<image>)
I was able to define c fairly easily. And I think I could write the function for the list of repeated circles, but using range is turning out to be tricky. I tried a few ways using repeated, but defining the transformation using range was unsuccessful. Until I got this! I think I was overthinking the whole thing, much simpler than I had originally assumed.
> (define circles n
(repeated (c 10) (+ n 10) 5))
define: expected only one expression after the variable name circles, but found 1 extra part
> (define (circles n)
(repeated (c 10) (+ n 10) 5))
circles: this name was defined previously and cannot be re-defined
> (define (circles3 n)
(repeated (c 10) (+ n 10) 5))
> (circles3 10)
function call: expected a function after the open parenthesis, but received 20
> (map c (range 10 55 5))
(list . . . . . . . . .)
> (map c (range 10 55 10))
(list . . . . .)
(repeated (c 10) (+ n 10) 5))
define: expected only one expression after the variable name circles, but found 1 extra part
> (define (circles n)
(repeated (c 10) (+ n 10) 5))
circles: this name was defined previously and cannot be re-defined
> (define (circles3 n)
(repeated (c 10) (+ n 10) 5))
> (circles3 10)
function call: expected a function after the open parenthesis, but received 20
> (map c (range 10 55 5))
(list . . . . . . . . .)
> (map c (range 10 55 10))
(list . . . . .)
I'll keep working, check in with any more issues...