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
12
votes
2 answers

How can I append a number to a string in Racket?

Python : xx = "p" + "y" + str(3) => xx == "py3" How can I get the same result using Racket? (string-append "racket" (number->string 5) " ") Is there another way in Racket, similar to the Python example above, to append a number to a string?
book-life
  • 149
  • 1
  • 5
12
votes
1 answer

difference between free-identifier=? and bound-identifier=?

Trying to understand free-identifier=? and bound-identifier=?. Can anyone give me equivalent code examples where using free-identifier=? would return true and using bound-identifier=? would return false. Thanks
jahhaj
  • 763
  • 4
  • 9
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
12
votes
1 answer

Call Racket function from C

I have a Racket module hw.rkt: #lang racket/base (provide hw) (define (hw) (displayln "Hello, world!")) I would like to write a C program that embeds the Racket runtime and applies the procedure (hw). There is example code here which demonstrates…
Arandur
  • 727
  • 6
  • 19
12
votes
3 answers

What is the definition of "natural recursion"?

The Third Commandment of The Little Schemer states: When building a list, describe the first typical element, and then cons it onto the natural recursion. What is the exact definition of "natural recursion"? The reason why I am asking is because I…
Aadit M Shah
  • 72,912
  • 30
  • 168
  • 299
12
votes
4 answers

What is the difference between a transparent and a prefab struct?

As the title implies, I don't understand the difference between using #:transparent and using #:prefab when defining a struct. The reference mentions that prefab involves some sort of global sharing. What is the difference between them? In which…
croyd
  • 1,075
  • 1
  • 11
  • 15
12
votes
1 answer

When is ->i actually useful in racket?

I've been going through Contracts in the Racket Guide. The ->i construct allows one to place arbitrary constraints on the input/output of a function. For example, I could have an unzip function that takes a list of pairs and returns two lists. Using…
Luke Miles
  • 941
  • 9
  • 19
12
votes
1 answer

How do you get the helpful tools in DrRacket?

My brother wanted to introduce me to lisp languages, so he showed me DrRacket on his computer. Everything looked awesome, including arrows that point to where a function is being imported from, and a documentation bubble of sorts that tells you the…
Mattstir
  • 175
  • 10
12
votes
2 answers

How can I use JSON's `jsexpr?` predicate with Typed Racket?

I'm trying to use the json package in Typed Racket, but I'm having some trouble handling how to type the jsexpr? predicate. My first attempt was simply using #:opaque. (require/typed json [#:opaque JSExpr jsexpr?]) The trouble is…
Alexis King
  • 43,109
  • 15
  • 131
  • 205
12
votes
2 answers

DrRacket crash on OS X 10.10 (Yosemite)?

I'm using DrRacket on the newest version of OS X, Yosemite, but when I open DrRacket the systems tells me that "DrRacket quit unexpectedly". I've already tried restarting the computer, and I'm sure the I have the 64-bit version of Racket, so what's…
Magi
  • 273
  • 2
  • 8
12
votes
1 answer

Lambda in Racket Explained

I am trying to understand lambda use in racket and I am still unclear. I get that they are unnamed (anonymous) functions but why is that good? I need to access my functions from other functions so how would I call them??? Please explain the small…
1Raptor007
  • 247
  • 1
  • 2
  • 10
12
votes
2 answers

How to know whether a racket variable is defined or not

How you can have a different behaviour if a variable is defined or not in racket language?
gaucib
  • 465
  • 4
  • 8
12
votes
1 answer

How do I set the language in the racket REPL

I would like to set the language that my racket REPL is using interactively, like this: -> #lang typed/racket ; readline-input:15:0: read: #lang not enabled in the current context [,bt for ; context] ; typed/racket: undefined; ; cannot reference…
djhaskin987
  • 9,741
  • 4
  • 50
  • 86
12
votes
3 answers

Pros and cons of MIT Scheme and DrScheme for studying SICP

What are the pros and cons of using MIT Scheme versus using DrScheme, in the context of trying to go through SICP (presumably simultaneously to watching some / all the MIT 6.001 videos)?
JDelage
  • 13,036
  • 23
  • 78
  • 112
12
votes
3 answers

How to turn a list of string into one string in scheme?

For example I have (list "a" "1" "b" "2" "c" "3"). Now I want to turn this list into one "a1b2c3". How do I do that? Thank you.
user2444642
  • 121
  • 1
  • 1
  • 3