racket Getting started with racket

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Remarks

This section provides an overview of what racket is, and why a developer might want to use it.

It should also mention any large subjects within racket, and link out to the related topics. Since the Documentation for racket is new, you may need to create initial versions of those related topics.

Versions

VersionDocumentationRelease date
Nightly buildsLatest Documentation2999-12-31
Version 6.9Documentation2017-04-01
Version 6.8Documentation2017-01-01
Version 6.7Documentation2016-10-01
Version 6.6Documentation2016-07-01
Version 6.5Documentation2016-04-01
Version 6.4Documentation2016-02-01
Version 6.3Documentation2015-11-01
Version 6.2.1Documentation2015-08-01
Version 6.2Documentation2015-06-01
Version 6.1.1Documentation2014-11-01
Version 6.1Documentation2014-08-01
Version 6.0.1Documentation2014-05-01
Version 6.0Documentation2014-02-01
Version 5.93Documentation2014-01-01
Version 5.92Documentation2014-01-01
Version 5.3.6Documentation2013-08-01
Version 5.3.5Documentation2013-06-01
Version 5.3.4Documentation2013-05-01
Version 5.3.3Documentation2013-02-01
Version 5.3.2Documentation2013-02-01
Version 5.3.1Documentation2012-11-01
Version 5.3Documentation2012-08-01
Version 5.2.1Documentation2012-03-01
Version 5.2Documentation2011-11-01
Version 5.1.3Documentation2011-08-01
Version 5.1.2Documentation2011-08-01
Version 5.1.1Documentation2011-04-01
Version 5.1Documentation2011-02-01
Version 5.0.2Documentation2010-11-01
Version 5.0.1Documentation2010-08-01
Version 5.0Documentation2010-06-01

Find Racket sources in all subdirs

#lang racket 
(for ([path (in-directory)]
  #:when (regexp-match? #rx"[.]rkt$" path))
  (printf "source file: ~a\n" path))
 

The #lang line specifies the programming language of this file. #lang racket we are using the baseline, battery-included Racket programming language. Other languages ranen from Racket flavors such as Type Racket (#lang typed/racket ) or the documentation language Scribble (#lang scribble ), to small convenience languages such as the language for defining packages (#lang info ).

The in-directory function constructs a sequence that walks a directory tree (starting with the current directory, by default) and generates paths in the tree. The for form binds path to each path in the sequence, and regexp-match? applies a pattern to the path.

To run the example, install Racket, start DrRacket, paste the example program into the top area in DrRacket, and click the Run button. Alternatively, save the program to a file and run racket from the command line on the file.

Hello, World!

The following example declares a piece of code to be written in Racket, and then prints the string Hello, world .

#lang racket
"Hello, world!"
 

Racket code can either be run directly from the command line or on the DrRacket IDE. Typing racket on the command line will start a REPL, and typing racket followed by a file name will evaluate the contents of the file. For example, suppose the file hello.rkt contains the above code. Here is an example of running Racket on the command line.

$ racket
Welcome to Racket v6.5.
> "Hello, world!"
"Hello, world!"
> (exit)
$ racket hello.rkt
"Hello, world!"
 

Installation or Setup

The installation is very simple. If you are used to this kind of thing, just go to https://download.racket-lang.org. If you prefer, there are more detailed step-by-step installation instructions for the following systems:

Racket

Racket is a full-spectrum programming language. It goes beyond Lisp and Scheme with dialects that support objects, types, laziness, and more. Racket enables programmers to link components written in different dialects, and it empowers programmers to create new, project-specific dialects. Racket's libraries support applications from web servers and databases to GUIs and charts.

The offical, comprehensive and very well-written documentation can be found at [http://docs.racket-lang.org/][1]. On this site (Stack Overflow Documentation) you can find user-contributed examples.

Installation

Go to http://racket-lang.org and click the download button.

Simple Recursive Function Definition

In Racket, we use recursion very frequently. Here is an example of a function that sums all of the numbers from zero to the parameter, n .

(define (sum n)
    (if (zero? n)
        0
        (+ n (sum (sub1 n)))))
 

Note that there are many helpful convenience based functions used here, such as zero? and sub1 . Each respectively does just what you might expect: zero? returns a boolean which says whether the given number was equal to zero, and sub1 subtracts one from its argument.



Got any racket Question?