racket-student-languages

Scheme Beginning Student, Function Body Extra Part

我怕爱的太早我们不能终老 提交于 2020-04-17 21:37:36
问题 I attempted to follow the solution provided in this question, but it simply didn't work. Essentially, my function works like so: (define (item-price size normal-addons premium-addons discount) (define price 0) (+ price (* normal-addon-cost normal-addons) (* premium-addon-cost premium-addons) size) (cond .. some conditions here [else price])) However, I am met with the following error: define: expected only one expression for the function body, but found 2 extra parts Now, I've tried wrapping

Scheme Beginning Student, Function Body Extra Part

送分小仙女□ 提交于 2020-04-17 21:37:31
问题 I attempted to follow the solution provided in this question, but it simply didn't work. Essentially, my function works like so: (define (item-price size normal-addons premium-addons discount) (define price 0) (+ price (* normal-addon-cost normal-addons) (* premium-addon-cost premium-addons) size) (cond .. some conditions here [else price])) However, I am met with the following error: define: expected only one expression for the function body, but found 2 extra parts Now, I've tried wrapping

BSL (How to Design Programs): how to import code from a separate file into definitions area?

若如初见. 提交于 2019-12-31 02:58:11
问题 I'm having an issue with BSL. I want to divide my code into separate auxiliary files and use (require "auxiliary-function.rkt") at the beginning to import the separated code into the definitions area. However it doesn't work as supposed. Though no explicit error given, it seems like that that DrRacket simply doesn't see the code in the separate file and all I see is the error <auxiliary-function-name>: this function is not defined Apparently, (provide x) is not included in BSL. I've read the

How to have ball collide with bricks in Breakout (racket)

◇◆丶佛笑我妖孽 提交于 2019-12-14 02:59:55
问题 I've been trying to get Breakout to work in Racket, so far the ball bounces from the paddle (paddle is controlled by mouse) and the bricks are present Here is the full on code: (require 2htdp/image) (require 2htdp/universe) (define WIDTH 400) (define HEIGHT 400) (define BALL-RADIUS 10) (define BALL-IMG (circle BALL-RADIUS "solid" "red")) (define REC-WIDTH 50) (define REC-HEIGHT 10) (define REC-IMG (rectangle REC-WIDTH REC-HEIGHT "solid" "grey")) (define BRICK-IMG0 (rectangle 60 30 "solid"

Why is this expression giving me a function body error?

谁说我不能喝 提交于 2019-12-11 07:18:23
问题 (define (subtract-1 n) (string-append "Number is: " (number->string n)) (cond [(= n 0) "All done!"] [else (subtract-1(- n 1))])) I keep getting the error: define: expected only one expression for the function body, but found 1 extra part. I'm not understanding why I'm getting this. NOTE TO SELF: When using DrRacket, Setting the language to BSL may make Racket commands error at compile time. 回答1: The language you're using (BSL) only allows a single expression inside the body of a procedure, if

BSL (How to Design Programs): how to import code from a separate file into definitions area?

元气小坏坏 提交于 2019-12-02 01:15:35
I'm having an issue with BSL. I want to divide my code into separate auxiliary files and use (require "auxiliary-function.rkt") at the beginning to import the separated code into the definitions area. However it doesn't work as supposed. Though no explicit error given, it seems like that that DrRacket simply doesn't see the code in the separate file and all I see is the error <auxiliary-function-name>: this function is not defined Apparently, (provide x) is not included in BSL. I've read the manual and this answer but it’s still not clear how to make this work. Is this even possible in BSL?