Hello,i have just bought this book called "realm of racket" really good book by the way ,i have learned a lot but i came across a code related to local definitions,i understand the purpose of the code and how it works but i cannot seem to get it to run,i try but i keep getting errors,i understand it takes two arguments.,though i don't know how to apply posn to the function.Here is the code
(struct posn ( x y))
(struct rectangle (width height))
(define (inside-of-rectangle? r p)
(define x (posn-x p))
(define y (posn-y p))
(define width (rectangle-width r))
(define height (rectangle-height r))
(and (<= 0 x) (< x width ) (<= 0 y) (< y height)))
i have tried running it in different ways but the problem persists can someone help me understand what i am doing wrong many thanks
(inside-of-rectangle? (posn? x))
. . x: undefined;
cannot reference an identifier before its definition
(inside-of-rectangle? (make-posn-x 1))
. . make-posn-x: undefined;
cannot reference an identifier before its definition
(inside-of-rectangle? (make-posn 1))
. . make-posn: undefined;
cannot reference an identifier before its definition
(inside-of-rectangle? (posn-x 4))
. . posn-x: contract violation
expected: posn?
given: 4
(inside-of-rectangle? (posn ( 2 5)))
. . application: not a procedure;
expected a procedure that can be applied to arguments
given: 2
(inside-of-rectangle? (posn? ( 2 5)))
. . application: not a procedure;
expected a procedure that can be applied to arguments
given: 2
(inside-of-rectangle? (posn? 3))
. . inside-of-rectangle?: arity mismatch;
the expected number of arguments does not match the given number
expected: 2
given: 1
(inside-of-rectangle? (posn? 3 4))
. . posn?: arity mismatch;
the expected number of arguments does not match the given number
expected: 1
given: 2
(inside-of-rectangle? (posn 3 4))
. . inside-of-rectangle?: arity mismatch;
the expected number of arguments does not match the given number
expected: 2
given: 1
(inside-of-rectangle? (posn 3 4) (rectangle 50 100))
. . posn-x: contract violation
expected: posn?
given: #
(inside-of-rectangle? (posn 3 4) (posn-x 4 5(rectangle 50 100)))
. . posn-x: arity mismatch;
the expected number of arguments does not match the given number
expected: 1
given: 3
(inside-of-rectangle? (posn 3 4) (posn-x 4 5)(rectangle 50 100))
. . posn-x: arity mismatch;
the expected number of arguments does not match the given number
expected: 1
given: 2
(inside-of-rectangle? (posn-x 4 5)(rectangle 50 100))
. . posn-x: arity mismatch;
the expected number of arguments does not match the given number
expected: 1
given: 2
(inside-of-rectangle? (posn-x 4 ) (posn-y 5))
. . posn-x: contract violation
expected: posn?
given: 4
(inside-of-rectangle? (posn (posn-x 4 ) (posn-y 5)))
. . posn-x: contract violation
expected: posn?
given: 4
(inside-of-rectangle? (posn (posn 4 ) (posn 5)))
. . posn: arity mismatch;
the expected number of arguments does not match the given number
expected: 2
given: 1
(inside-of-rectangle? (posn (posn 4 5) (posn 5)))
. . posn: arity mismatch;
the expected number of arguments does not match the given number
expected: 2
given: 1
(inside-of-rectangle? (posn (posn 4 5) (posn 5 6)))
. . inside-of-rectangle?: arity mismatch;
the expected number of arguments does not match the given number
expected: 2
given: 1
(inside-of-rectangle? (posn (posn 4 5) (posn 5 6)) (rectangle 40 50))
. . posn-x: contract violation
expected: posn?
given: #
(inside-of-rectangle? (posn (posn 4 5) (posn 5 6)) ((rectangle 40 50)))
. . application: not a procedure;
expected a procedure that can be applied to arguments
given: #
(posn-x 4)
. . posn-x: contract violation
expected: posn?
given: 4
(posn? 4)
#f
(posn-x p)
. . p: undefined;
cannot reference an identifier before its definition
(posn-x x)
. . x: undefined;
cannot reference an identifier before its definition
(posn-x x)
. . x: undefined;
cannot reference an identifier before its definition
(make-posn 3 4)
. . make-posn: undefined;
cannot reference an identifier before its definition