Questions tagged [racket]

Racket is an extensible multi-paradigm programming language in the Lisp/Scheme family.

Racket is a general purpose, multi-paradigm programming language in the Lisp/Scheme family. One of its design goals is to serve as a platform for language creation, design, and implementation. The language is used in a variety of contexts such as scripting, general-purpose programming, computer science education, and research.

Racket Programming Books

Racket documentation is well written and directly accessible from within the DrRacket IDE. It has two great tutorials: one on web applications and one about systems programming.

A great tutorial on macros.

History: Racket was initially called PLT Scheme.

Questions about BSL, HTDP, and other student languages should go into the racket-student-languages tag instead.

5811 questions
20
votes
4 answers

How do I do anything with multiple return values in racket?

It seems like in order to use multiple return values in Racket, I have to either use define-values or collect them into a list with (call-with-values (thunk (values-expr)) list). In the latter case, why would someone to choose to return multiple…
Matt G
  • 1,661
  • 19
  • 32
20
votes
1 answer

Vi Keybindings in DrRacket

Has anyone got any idea if drracket editor has got vi keybindings or if there is a plugin for that can activate vi keybindings within drracket?
cobie
  • 7,023
  • 11
  • 38
  • 60
19
votes
2 answers

Racket reader macros

Is there any way to make simple reader macros in Racket. I mean a generalization like this: (define-reader-syntax "'" quote) ; finds expressions that start with "'" and wraps them in `(quote ...)` '(foo) ; => (quote (foo)) 'foo ; => (quote foo) I…
adrusi
  • 835
  • 1
  • 7
  • 14
19
votes
4 answers

Why doesn't Scheme support first class environments?

I've been reading through SICP (Structure and Interpration of Computer Programs) and was really excited to discover this wonderful special form: "make-environment", which they demonstrate to use in combination with eval as a way of writing modular…
Paul Hollingsworth
  • 13,124
  • 12
  • 51
  • 68
19
votes
3 answers

Including an external file in racket

I would like to include all the functions defined in a given racket file so that I get the same effect as if they were copied. Is it possible to do that?
D R
  • 21,936
  • 38
  • 112
  • 149
19
votes
4 answers

In Racket, what is the advantage of lists over vectors?

In my experience with Racket so far, I've not given much thought to vectors, because I gathered that their main benefit — constant-time access to elements — was not significant until you're working with lot of elements. This doesn't seem quite…
Matthew Butterick
  • 1,064
  • 3
  • 12
  • 22
19
votes
3 answers

Use of lambda for cons/car/cdr definition in SICP

I was just beginning to feel I had a vague understanding of the use of lambda in racket and scheme when I came across the following 'alternate' definitions for cons and car in SICP (define (cons x y) (lambda (m) (m x y))) (define (car z) (z…
Penguino
  • 2,136
  • 1
  • 14
  • 21
17
votes
2 answers

Check if an argument is a list or an atom

How do I check if something is an atom? I'm looking for something like number? or list?.
Koen
  • 265
  • 1
  • 3
  • 8
17
votes
7 answers

removing last element of a list(scheme)

So I have to remove the last element of a list in scheme. For example, let's say I have a list (1 2 3 4). I need to return: (1 2 3) My idea: reverse(list) car(list) reverse(list) Is there a reverse function in scheme(racket)?
anon
17
votes
3 answers

Is there a shorthand way to update a specific struct field in racket?

Suppose I have a struct with many fields: (struct my-struct (f1 f2 f3 f4)) If I am to return a new struct with f2 updated, I have to rephrase every other fields: (define s (my-struct 1 2 3 4)) (my-struct (my-struct-f1 s) (do-something-on…
shouya
  • 2,863
  • 1
  • 24
  • 45
17
votes
3 answers

What are the benefits of letrec?

While reading "The Seasoned Schemer" I've begun to learn about letrec. I understand what it does (can be duplicated with a Y-Combinator) but the book is using it in lieu of recurring on the already defined function operating on arguments that remain…
Ixmatus
  • 1,051
  • 9
  • 15
17
votes
2 answers

How do I get an item from a list at a given index in racket language?

I'm trying to get an item from a list at a given index for a loop statement. (define decision-tree-learning (lambda (examples attribs default) (cond [(empty? examples) default] [(same-classification? examples) (caar examples)] ;…
lu1s
  • 5,600
  • 3
  • 22
  • 37
16
votes
2 answers

The advantage of Arc over Racket

Arc is built on top of Racket. Since both of them are in the Lisp family, I am curious about the the advantage of Arc over Racket, or what is the motivation of creating Arc given that Racket is available?
Ning
  • 2,850
  • 2
  • 16
  • 23
16
votes
0 answers

Is a function that curries the first argument of a list of functions typeable in Typed Racket?

I can write a simple function in untyped Racket called curry-all that takes a list of functions, all of which accept the same kind of value for their first argument, and produces a list of functions with their first arguments curried. (define…
Alexis King
  • 43,109
  • 15
  • 131
  • 205
16
votes
5 answers

About "If.." in Scheme (plt-scheme)

I had a pretty simple requirement in my Scheme program to execute more than one statement, in the true condition of a 'if'. . So I write my code, something like this: (if (= 1 1) ((expression1) (expression2)) ; these 2 expressions are to be …
user59634