Questions tagged [htdp]

HtDP refers to the book "How to Design Programs". Use this tag both for questions concerning exercises from the book and for questions regarding the teaching HtDP teaching languages in DrRacket. https://htdp.org/

HtDP refers to the book "How to Design Programs".

Use this tag both for questions concerning exercises from the book and for questions regarding the teaching HtDP teaching languages in DrRacket.

https://htdp.org/

48 questions
24
votes
1 answer

Differences between #lang scheme and #lang racket

I'm guessing that #lang racket is a dialect of scheme with much more out of the box structures and common functions and perhaps would be more pedagogic. What are the perks a #lang racket against #lang scheme? Is it best (or even possible) to use…
orlybg
  • 599
  • 1
  • 5
  • 15
13
votes
4 answers

How to make a GUI using Lisp: DrScheme or Common Lisp

Or the basic work need to do to create a GUI. I know the basic Components of GUI, but where to begin. I'm just a self-study person and I'm reading "How to Design Program" (HtDP) at the end of the book the author suggest that knowledge of GUI and CGI…
user1472
  • 131
  • 1
  • 1
  • 3
12
votes
4 answers

Performance of recursion vs accumulator style

We have two functions that compute the factorial of a given number. The first one, !, uses an accumulator style. The second, fact, uses natural recursion. (define (! n0) (local (;; accumulator is the product of all natural numbers in [n0, n) …
Greenhorn
  • 411
  • 1
  • 6
  • 14
11
votes
1 answer

Overlapping module imports in Racket

I want to load an image and animate it in Racket. I can do it easily in the Dr. Racket, but I am using Emacs with Geiser. To load the image I need to: (require racket/draw) Next, to draw this image onto the screen, I'm planning to use the big-bang…
Roald
  • 231
  • 1
  • 12
9
votes
1 answer

*Excruciatingly* slow (over ten seconds for `(+ 1 1)`) with language "How To Design Programs - Beginning Student"

I just installed DrRacket, and tried out the language "How To Design Programs - Beginning Student". Racket - A programmable programming language Racket - Getting Started I run (+ 1 1), and it takes over ten seconds for this to show up: Welcome to…
Owen_AR
  • 2,867
  • 5
  • 20
  • 23
7
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
  • 9,805
  • 5
  • 46
  • 92
7
votes
5 answers

How to do a powerset in DrRacket?

I'm using the beginning language with list abbreviations for DrRacket and want to make a powerset recursively but cannot figure out how to do it. I currently have this much (define (powerset aL) (cond [(empty? aL) (list)] any help would be…
user3109171
  • 79
  • 1
  • 1
  • 2
7
votes
1 answer

Selecting student language in Racket source code

I am trying to write a source file for DrRacket that specifies one of the languages from How to Design Programs Teaching Languages (see the Racket documentation). I know I can select such a language in the DrRacket menu, but I would like to specify…
Giorgio
  • 5,023
  • 6
  • 41
  • 71
6
votes
3 answers

Use of local in Racket/Scheme

In Exercise 18.1.12 from htdp, I've re-written the maxi function using "local". ;; maxi : non-empty-lon -> number ;; to determine the largest number on alon (define (maxi alon) (cond [(empty? (rest alon)) (first alon)] [else (local…
Greenhorn
  • 411
  • 1
  • 6
  • 14
5
votes
1 answer

Executing Racket Beginning Student scripts in terminal without wrapping in a module

I try to execute a script written in one of the Teaching Languages (e.g. Beginning Student) delivered with DrRacket environment. I can achieve that by wrapping the code into a module (just like DrRacket does): #reader(lib "htdp-beginner-reader.ss"…
Robson
  • 813
  • 5
  • 21
  • 40
5
votes
2 answers

Difference between 1st and 2nd version of "How to Design Programs" (HTDP)

i searched the internet for hours, but didn't find a satisfying answer to what's the difference between the first and second version of HTDP (How to design programs)? Why should I start with the second version, instead of the first one? As the…
cobby
  • 484
  • 3
  • 18
5
votes
3 answers

PLT-Scheme learning reference

After having got through the two Schemer books, I'm about to embark on HtDP but also discovered the http://docs.plt-scheme.org/guide material. The previously mentioned books are more particular to Scheme, it seems, and the latter being more geared…
Ixmatus
  • 1,051
  • 9
  • 15
4
votes
2 answers

Why is this legal (racket) scheme?

I was going through htdp and found this somewhere in the beginning :- Explain why the following sentences are illegal definitions: 1. (define (f 'x) x) However, it works fine in racket: > (define (f 'x) x) > (f 'a) 3 > (define a 5) > (f…
agam
  • 5,064
  • 6
  • 31
  • 37
4
votes
1 answer

Why can't I make two make function calls in function body?

So I'm going through the first chapter of How To Design Programs 2nd Edition. I believe I made pretty good progress. But there's a "suggestion" to add another graphic to the grid. Every time I try I get an error. At this point, I'm stuck. Below is…
dotnetN00b
  • 5,021
  • 13
  • 62
  • 95
4
votes
1 answer

Why does the book How to Design Programs chose this approach on their answer sheet?

I am using the famous book How to Design Programs. More specifically, the first edition (I have the physical one). In the 6th chapter, there are some exercises with Structures. In one of them, you need to simulate traffic lights and use effects…
Pedro Delfino
  • 2,421
  • 1
  • 15
  • 30
1
2 3 4