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

What is difference between datum->syntax and syntax #' in define-syntax body?

Testing code: (define-syntax (test-d stx) #'(begin (define (callme a) (writeln a)))) (define-syntax (test-e stx) (datum->syntax stx '(begin (define (callme2 a) (writeln…
Ondrej
  • 503
  • 3
  • 21
8
votes
1 answer

Parallel running of Racket code for N-Queens problem

I am using following simple code to solve n-queens problem: #lang racket ; following returns true if queens are on diagonals: (define (check-diagonals bd) (for/or ((r1 (length bd))) (for/or ((r2 (range (add1 r1) (length bd)))) (=…
rnso
  • 23,686
  • 25
  • 112
  • 234
8
votes
3 answers

Why do some lisps put the function name outside of the argument list in a function definition?

common lisp and clojure do (defn function-name (arg1 arg2) (body)) racket/scheme does (defn (function-name arg1 arg2) (body)) The latter makes more sense to me because the syntax for function definition and invocation is similar. What's the…
Boris Verkhovskiy
  • 14,854
  • 11
  • 100
  • 103
8
votes
2 answers

How do collector functions work in Scheme?

I am having trouble understanding the use of collector functions in Scheme. I am using the book "The Little Schemer" (by Daniel P. Friedman and Matthias Felleisen). A comprehensive example with some explanation would help me massively. An example of…
CPUFry
  • 566
  • 4
  • 18
8
votes
1 answer

Module meta-language in Racket

I'm trying to write in Racket a module meta-language mylang, which accepts a second language to which is passes the modified body, such that: (module foo mylang typed/racket body) is equivalent to: (module foo typed/racket transformed-body) where…
Suzanne Soy
  • 3,027
  • 6
  • 38
  • 56
8
votes
1 answer

What is (lambda lambda lambda)?

My friend shows this to me, and I am really curious why it works like this. I at first thought that it's gonna be a syntax error, but it doesn't... Here're some of my experiments: > (lambda lambda lambda) # > ((lambda lambda…
Sorawee Porncharoenwase
  • 6,305
  • 1
  • 14
  • 28
8
votes
2 answers

How to test if two functions are the same?

I found a code snippet somewhere online: (letrec ([id (lambda (v) v)] [ctx0 (lambda (v) `(k ,v))] ..... ..... (if (memq ctx (list ctx0 id)) <---- condition always return false ..... where ctx is also a…
齐天大圣
  • 1,169
  • 5
  • 15
  • 36
8
votes
1 answer

Specify #lang for eval in Racket

I want to use a specific #lang in eval to provide it its semantics. However, eval itself does not appear to have a mechanism to specify the language, and passing in #lang does not seem to work.
ckfinite
  • 427
  • 2
  • 6
8
votes
5 answers

(define (average ....)) in Lisp

I'm just playing around with scheme/lisp and was thinking about how I would right my own definition of average. I'm not sure how to do some things that I think are required though. define a procedure that takes an arbitrary number of…
Eric Schoonover
  • 47,184
  • 49
  • 157
  • 202
8
votes
2 answers

The Little Schemer: What is a function or argument's structure?

In Chapter 3 of The Little Schemer, the answer to the question of why we don't simplify the rember function right away is "because then a function's structure does not coincide with its argument's structure." I'm having trouble understanding what a…
8
votes
5 answers

Adding an element to List in Scheme

Below is my code which takes a car element of a list(carVal) and an list(initialized to empty) as parameters. I want to append the element to the list but the same is not working. (define populateValues (lambda (carVal currVal) (append…
name_masked
  • 9,544
  • 41
  • 118
  • 172
8
votes
1 answer

Scheme: CAR and CDR of a list

I am confused as to how car and cdr work on lists. Here is an example of what I have tried: (define sample (read)) (display sample) (display (car sample)) (display (cdr sample)) (display (car (cadr sample))) (display (cdr (cdr sample))) On…
name_masked
  • 9,544
  • 41
  • 118
  • 172
8
votes
1 answer

How to filter out false values from the list in racket

I'm learning Racket (but probably answer will be similar in any Scheme and scheme-derived language) and wonder how to filter out false (#f) values from a given list. The best I came up with is: (filter (lambda (x) (not (eq? x #false))) …
radious
  • 812
  • 6
  • 21
8
votes
1 answer

In Racket's class system, what do augment, overment, augride, etc. do?

Racket's documentation only partially describe what augment and pubment do: augment makes a method that executes after the superclass's version of that method, while pubment makes a method that will implicitly have the augment property if it is…
Throw Away Account
  • 2,593
  • 18
  • 21
8
votes
2 answers

For-each and map in Scheme

Are there any difference between these 2 functions in scheme?I am using Dr Racket R5RS language to make a simulator game and I could not decide which one is better.
Prethia
  • 1,183
  • 3
  • 11
  • 26