scheme - Why am I getting this body error? -


every time run code, error message: "define: expected 1 expression function body, found 1 part." have tried again , again fix this, haven't found solutions. have idea of how can fix it? sorry long code, figured should include or wouldn't make sense. thanks!

(define mt (empty-scene 50 50))  ; polygon 1 of:  ; – (list posn posn posn) ; – (cons posn polygon)  ; nelop 1 of:  ; – (cons posn empty) ; – (cons posn nelop)  ; polygon -> image  ; adds image of p mt (define (render-polygon p)   (local      [;polygon -> posn      ; extracts last item p      (define (last p)         (cond          [(empty? (rest (rest (rest p)))) (third p)]          [else (last (rest p))]))]     [;image posn posn -> image      (define (render-line im p q)        (add-line         im (posn-x p) (posn-y p) (posn-x q) (posn-y q) "red"))]     [;nelop -> image      ;connects posns in p in image      (define (connect-dots p)        (cond          [(empty? (rest p)) mt]          [else           (render-line            (connect-dots (rest p)) (first p) (second p))]))])   (render-line (connect-dots p) (first p) (last p))) 

new code (still not working):

; polygon -> image  ; adds image of p mt (define (render-polygon p)   (local      [;polygon -> posn      ; extracts last item p      (define (last p)         (cond          [(empty? (rest (rest (rest p)))) (third p)]          [else (last (rest p))]))     ;image posn posn -> image      (define (render-line im p q)        (add-line         im (posn-x p) (posn-y p) (posn-x q) (posn-y q) "red"))     ;nelop -> image      ;connects posns in p in image      (define (connect-dots p)        (cond          [(empty? (rest p)) mt]          [else           (render-line            (connect-dots (rest p)) (first p) (second p))]))   (render-line (connect-dots p) (first p) (last p))])) 

your render-line expression has inside local form, not after it. also, defines should inside one subform in local, not each in own subform. so, should like:

(local [(define (last p)           ...)         (define (render-line im p q)           ...)         (define (connect-dots p)           ...)]   (render-line ...)) 

Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -