#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.