Questions tagged [racket-student-languages]

The Racket Student Languages are a set of small languages meant to be used with the book How to Design Programs. They include Beginning Student Language (BSL and BSL+), Intermediate Student Language (ISL), Intermediate Student Language with Lambda (ISL+), and Advanced Student Language (ASL)

38 questions
6
votes
2 answers

How to set language to htdp/bsl in REPL

I have the following htdp/bsl program saved as example.rkt: #lang htdp/bsl (+ 1 1) When the above is run using racket example.rkt, the output is as expected (i.e. 2). However, when I try to start an REPL with htdp/bsl as the language (racket -I…
Flux
  • 5,866
  • 4
  • 24
  • 62
4
votes
1 answer

New to programming, question about exercise in Prologue of HTDP

This may be a silly question but I'm completely new to programming. I'm towards the bottom of the Prologue in "How to Design Programs" (2nd ed) and there are 4 changes that you are challenged to make to the "Rocket Landing" program in DrRacket. I'm…
Asif Kazmi
  • 43
  • 4
3
votes
2 answers

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

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…
dekross
  • 104
  • 1
  • 7
3
votes
2 answers

scheme how to return a form symbol + *

How can I define on scheme language this function that return if x>0 + else * like: plus_or_muliti(int x) { if (x>0) return +; else return *; } i try this and it not work on racket: (define (plus_or_multi x) (if (>= x 0) + *)) i got this…
2
votes
1 answer

What makes my image look half as wide as intended?

I am trying to place a vertically positioned rectangle and another object on an empty-scene using place-images in Beginning Student Language. However, when I run the function, the rectangle only takes up half the scene horizontally when its width is…
O1G
  • 37
  • 4
2
votes
0 answers

Is it possible to use `provide` in Racket's Student Language?

2.rkt has the following definition: (provide plus) (define (plus a b) (+ a b)) and 1.rkt has: (require "2.rkt") (plus 3 4) Both are in "Beginning Student Language" level (so no #lang line required) and are in the same directory. This leads to…
Atharva Shukla
  • 1,944
  • 5
  • 18
2
votes
2 answers

Programming Breakout in Racket (BSL) using big-bang. Running into an error upon placing the paddle

The goal is to make the game Breakout and doing it by steps. I'm already having problems with the first step which is implementing a paddle. The ball and bouncing of the ball was already predefined and given. I wish to put it in the (define (render…
2
votes
2 answers

place-image not defined in Dr-Racket

I wrote a simple code in Dr-Racket and it is not working. Here is the code: (place-image (circle 5 "solid" "green") 50 80 (empty-scene 100 100)) I have selected the BSL language for compiling but it is giving me the…
user590849
  • 10,883
  • 25
  • 77
  • 121
1
vote
1 answer

Why does the list result returned by my function look funny?

(define (evenList xs) (cond ((null? xs) '()) ((eq? (cdr xs) '()) '()) (else (cons (cadr xs) (evenList (cddr xs)))))) I'm using this code but it doesn't create the list the way I want it. (evenList (list 1 2 3 4))…
1
vote
2 answers

How to optimize runtime on recursive Racket function to determine maximum of element in list?

here is my wonderful & working LISP racket "intermediate with lambda" style recursive function to determine the symbol with the highest value of symbols in a list. (define maximum (lambda [x] (cond [(empty? x) 0] [(cons? x) …
Ben Jordan
  • 136
  • 7
1
vote
1 answer

Dr racket define error in student language. define: expected only one expression for the function body, but found 3 extra parts

When I write code in Dr Racket, I got error message unsaved-editor:8:2: define: expected only one expression for the function body, but found 3 extra parts in: (define (improve guess x) (average guess (/ x guess))) But this code can run in…
Namk0207
  • 45
  • 4
1
vote
2 answers

calculate the sum of proper divisors of a given number in Racket BSL

Design a Racket function named findProperDivisor that takes a natural number and calculates the sum of all its proper divisors. A proper divisor of a natural number is the divisor that is strictly less than the number. Examples: Input: 20 Output:…
1
vote
1 answer

Functions operating on two lists

I am working on a Racket program for a class and I am totally stumped as to how to implement one of the features. The program uses Big-Bang and is supposed to implement a simple Space Invaders game. I have everything working except one piece, and…
julieb
  • 35
  • 4
1
vote
1 answer

Work with binary search trees in Racket

I want to create a binary search tree in Racket. The structure for tree looks like this: (define-struct tree-node (left right root)) Now I want to add these numbers in the tree: (define ex-list (list 1 4 6 2 7 8)) My Code for the insert…
user5331311
1
vote
2 answers

DrRacket: put two objects into big-bang

How can i put two objects with its own coordinates (define padle1 (rectangle 10 30 "solid" "red")) (define padle2 (rectangle 10 30 "solid" "red")) (define (place-dot-at ... ) ...) into bin-bang function (big-bang ... [to-draw place-dot-at]) Can i…
demsee
  • 53
  • 6
1
2 3