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
29
votes
1 answer

What is the difference between [ ] and ( ) brackets in Racket (lisp programming language)?

It seems to me that technically both are interchangeable but have different conventional meanings.
Mahathi Vempati
  • 1,238
  • 1
  • 12
  • 33
29
votes
3 answers

When did the idea of macros (user-defined code transformation) appear?

I have read McCarthy's 1960 paper on LISP and found no reference to anything that's similar to user-defined macros or normal order evaluation. I was wondering when macros first appeared in programming language history (and also in Lisp…
Jay
  • 9,585
  • 6
  • 49
  • 72
28
votes
2 answers

How do you load a file into racket via command line?

I have been trying to launch a racket program from the commandline (via 'racket') but have not been having success. According to the documentation (here http://docs.racket-lang.org/reference/running-sa.html#%28part._mz-cmdline%29) passing -f…
Michael McGuinness
  • 283
  • 1
  • 3
  • 4
26
votes
3 answers

How can I get the previous command in DrRacket?

Like Racket - how to get the “previous executed command” in bash script? but with DrRacket. How can I get the previously executed command in DrRacket (like up arrow function in bash)?
Zan RAKOTO
  • 903
  • 9
  • 14
26
votes
2 answers

Racket Interactive vs Compiled Performance

Whether or not I compile a Racket program seems to make no difference to the runtime performance. Is it just the loading of the file initially that is improved by compilation? In other words, does running racket src.rkt do a jit compilation on the…
Scott Klarenbach
  • 37,171
  • 15
  • 62
  • 91
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
24
votes
3 answers

Racket vs Scheme macros

Do racket macros have more advanced functionality than those found in Scheme or Common Lisp? I suspect so, especially regarding modules, namespaces and scoping, etc, but I'd appreciate a simple rundown of what Racket macros can do, if anything,…
Scott Klarenbach
  • 37,171
  • 15
  • 62
  • 91
23
votes
3 answers

How to run scheme with Emacs?

I followed this tutorial and successfully installed Emacs, STk, Quack. The question is how can I load my program like I do in Racket? In Racket I can edit my code in the upper window, type some codes, save and run. Then the lower window will…
Juanito Fatas
  • 9,419
  • 9
  • 46
  • 70
23
votes
6 answers

What is scheme's equivalent of tuple unpacking?

In Python, I can do something like this: t = (1, 2) a, b = t ...and a will be 1 and b will be 2. Suppose I have a list '(1 2) in Scheme. Is there any way to do something similar with let? If it makes a difference, I'm using Racket.
Jason Baker
  • 192,085
  • 135
  • 376
  • 510
23
votes
2 answers

Converting String to integer in Scheme

How can I convert a string of digits to an integer ? I want "365" to be converted to 365. What I have tried, string->list then char->integer, but this returns ASCII value of that integer, how can I get that integer ? Please help.
Hari Chaudhary
  • 630
  • 1
  • 7
  • 20
22
votes
2 answers

Is there an autocomplete for Dr. Racket?

I usually use Sublime text editor and gnome terminal to edit and run my programs. Due to educational purposes, I am using the IDE Dr. Racket. I could not find an autocomplete feature to use while typing. I checked this out on google and at Dr.…
user4206400
22
votes
1 answer

Can `match` in Racket have patterns with variables from an outer scope?

Consider the following example: #lang racket (match '(cat . doge) [`(,a . ,b) (match b [a #t] [_ #f])] [_ "Not a pair"]) This is what I might write if I wanted to match pairs where the head and tail are the same. This doesn't work…
Chris Brooks
  • 725
  • 6
  • 15
21
votes
3 answers

set-car!, set-cdr! unbound in racket?

I am just trying to do very simple code with set-car! and set-cdr! in racket, but I got the error: expand: unbound identifier in module in: set-car! and expand: unbound identifier in module in: set-cdr! Aren't they defined in racket? Could anyone…
SoftTimur
  • 5,630
  • 38
  • 140
  • 292
21
votes
1 answer

Setting default argument value in Racket

Is it possible to set a default value to some of arguments in Racket? Like so in Python: def f(arg=0) ...
Vladimir Keleshev
  • 13,753
  • 17
  • 64
  • 93
21
votes
3 answers

Setting language with #lang in the REPL

I would like to set the language in the REPL on the fly, with #lang, not using "-I" command-line argument. But this gives me the error "read: #lang not enabled in the current context". Is there a command-line switch that I'm missing? Or maybe a…
Davor Cubranic
  • 1,051
  • 10
  • 16