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
3 answers

How do I find the index of an element in a list in Racket?

This is trivial implement of course, but I feel there is certainly something built in to Racket that does this. Am I correct in that intuition, and if so, what is the function?
Alex V
  • 3,416
  • 2
  • 33
  • 52
12
votes
3 answers

Newline in Scheme (Racket)

It is possible to have a new line when you write with "display" like (display "exa \n mple") But the problem is that there is no any code to have a new line in strings? Like: "exa \n mple" Expected -> exa mple What I have: exa \n mple I…
Asqan
  • 4,319
  • 11
  • 61
  • 100
12
votes
6 answers

What are lightweight lisp dialects that compile to readable js?

What are lisp dialects that compile to short, readable and modifiable JS, using JS's own types?
MaiaVictor
  • 51,090
  • 44
  • 144
  • 286
12
votes
2 answers

Should macros have side effects?

Can (or should) a macro expansion have side effects? For example, here is a macro which actually goes and grabs the contents of a webpage at compile time: #lang racket (require (for-syntax net/url)) (require (for-syntax…
Ord
  • 5,693
  • 5
  • 28
  • 42
12
votes
2 answers

I got "scheme application not a procedure" in the last recursive calling of a function

so here is the code: (define (time-prime-test n) (newline) (display n) (start-prime-test n (runtime))) (define (start-prime-test n start-time) (if (prime? n) (report-prime (- (runtime) start-time)))) (define (report-prime…
tuo
  • 586
  • 1
  • 4
  • 20
12
votes
2 answers

Trying to create a date from a string in Racket - find-seconds VERY slow, week-day year-day required?

I'm trying to parse dates from a large csv file in Racket. The most straightforward way to do this would be to create a new date struct. But it requires the week-day and year-day parameters. Of course I don't have these, and this seems like a real…
Scott Klarenbach
  • 37,171
  • 15
  • 62
  • 91
12
votes
1 answer

Racket flymake-mode for emacs

Is it possible to make flymake-mode be aware of syntax (or other) errors in racket files like it done for example for erlang or python? I'm using geiser-mode for racket, if it is matters.
gordon-quad
  • 734
  • 5
  • 15
12
votes
1 answer

Can Racket macros take keyword arguments?

I'd like to create a syntactic form in Racket that can accept a keyword argument, the way some functions can. Having reduced it to a simple example, I tried writing: (define-syntax sum-of-products (syntax-rules (#:extra) [(sum-of-products ([a…
Taymon
  • 24,950
  • 9
  • 62
  • 84
11
votes
1 answer

mcons in dr racket

I'm having trouble reading output from dr racket. By default it displays lists using mcons. For example, sicp exercise 2.32 produces: > (subsets (list 1 2 3)) (mcons (mcons '() (mcons (mcons 3 '()) (mcons (mcons 2 '()) (mcons …
Dmitri
  • 153
  • 1
  • 10
11
votes
4 answers

Best way to do input with racket?

What's the best way to read input from stdin in racket? In particular I'd like something like cin from c++ or scanf from c where I specify the types of things I want read and they are returned.
Cam
  • 14,930
  • 16
  • 77
  • 128
11
votes
2 answers

How to access syntax-class attributes in `~optional` that contains ellipsis?

TL;DR I'm trying to expand an optional ellipsis (~optional datum:my-class ...) into a form that uses attributes from my-class like so: #'(list datum.attr ...). But as the form is optional, when it's not present, it resolves to #f, which the ellipsis…
Zoé Martin
  • 1,887
  • 1
  • 16
  • 28
11
votes
1 answer

What is the convention for Racket filename extensions?

.rkt is the conventional file extension for 'regular' Racket source code. In the documentation, I also see .rktl and .rkts being used. What are .rktl and .rkts used for, and are there any more Racket filename extensions I am not aware of?
Flux
  • 9,805
  • 5
  • 46
  • 92
11
votes
2 answers

How do I step through and debug a Scheme program using Dr. Racket?

I'm using the Dr. Racket development environment and the language definition #lang scheme to do work for a course. However, I'm not sure how to best use this tool for debugging. I would like to be able to execute a function and step through it,…
Thomas Owens
  • 114,398
  • 98
  • 311
  • 431
11
votes
1 answer

Where does raco install packages?

Where would a raco pkg install --auto drracket install the drracket package by default? This is off of a preexisting homebrew installation of racket.
Kinnard Hockenhull
  • 2,790
  • 5
  • 27
  • 34
11
votes
4 answers

Lisp-family: how to escape object-oriented java-like thinking?

Backstory: I've made a lot of large and relatively complex projects in Java, have a lot of experience in embedded C programming. I've got acquainted with scheme and CL syntax and wrote some simple programms with racket. Question: I've planned a…
artemonster
  • 744
  • 4
  • 27