I am currently completing chapter 7 of the htdp book and am trying to create an instance of the spider structure:
#lang racket
;; spider-structure: structure -> ???
;; defines a spider structure with two parameters: legs and volume
(define-struct spider (legs volume))
;; spidercheck: lambda -> num
;; creates a spider check function and determines volume based on legs
(define spidercheck
(lambda (legs)
(cond
((<= legs 4) 800)
((> legs 4) 1000))))
(define a-spider
(make-spider 4
(spidercheck ...
My problem is that I want to pass the number from (make-spider 4)
to the spidercheck
function within the a-spider
function. I have tried (spider-legs a-spider)
but of course it says it is used before its definition. Any help is appreciated.
Thanks!