small improvements to style of examples on front page
This commit is contained in:
parent
cd2b2f83bb
commit
5f11b06dc4
|
@ -64,9 +64,9 @@
|
||||||
(generic-example #:title "Find Racket files" ; -----------------------------------------------
|
(generic-example #:title "Find Racket files" ; -----------------------------------------------
|
||||||
@code{#lang racket
|
@code{#lang racket
|
||||||
;; Finds Racket sources in all subdirs
|
;; Finds Racket sources in all subdirs
|
||||||
(for ([path (in-directory)])
|
(for ([path (in-directory)]
|
||||||
(when (regexp-match? #rx"[.]rkt$" path)
|
#:when (regexp-match? #rx"[.]rkt$" path))
|
||||||
(printf "source file: ~a\n" path)))}
|
(printf "source file: ~a\n" path))}
|
||||||
@desc{The @elemcode{in-directory} function constructs a sequence that
|
@desc{The @elemcode{in-directory} function constructs a sequence that
|
||||||
walks a directory tree (starting with the current directory, by default)
|
walks a directory tree (starting with the current directory, by default)
|
||||||
and generates paths in the tree. The @elemcode{for} form binds
|
and generates paths in the tree. The @elemcode{for} form binds
|
||||||
|
@ -97,11 +97,11 @@
|
||||||
(generic-example #:title "Unique Lines"; -----------------------------------------------
|
(generic-example #:title "Unique Lines"; -----------------------------------------------
|
||||||
@code{#lang racket
|
@code{#lang racket
|
||||||
;; Report each unique line from stdin
|
;; Report each unique line from stdin
|
||||||
(let ([saw (make-hash)])
|
(define seen (make-hash))
|
||||||
(for ([line (in-lines)])
|
(for ([line (in-lines)])
|
||||||
(unless (hash-ref saw line #f)
|
(unless (hash-ref seen line #f)
|
||||||
(displayln line))
|
(displayln line))
|
||||||
(hash-set! saw line #t)))}
|
(hash-set! seen line #t))}
|
||||||
@desc{Uses a hash table to record previously seen lines. You can run this
|
@desc{Uses a hash table to record previously seen lines. You can run this
|
||||||
program in DrRacket, but it makes more sense from the command line.}))
|
program in DrRacket, but it makes more sense from the command line.}))
|
||||||
@; Additional examples: -------------------------------------------
|
@; Additional examples: -------------------------------------------
|
||||||
|
@ -110,10 +110,10 @@
|
||||||
@code{#lang racket ; A picture
|
@code{#lang racket ; A picture
|
||||||
(require 2htdp/image)
|
(require 2htdp/image)
|
||||||
(let sierpinski ([n 8])
|
(let sierpinski ([n 8])
|
||||||
(if (zero? n)
|
(cond
|
||||||
(triangle 2 'solid 'red)
|
[(zero? n) (triangle 2 'solid 'red)]
|
||||||
(let ([t (sierpinski (- n 1))])
|
[else (define t (sierpinski (- n 1)))
|
||||||
(freeze (above t (beside t t))))))}
|
(freeze (above t (beside t t)))]))}
|
||||||
@desc{The @elemcode{2htdp/image} library provides easy-to-use functions
|
@desc{The @elemcode{2htdp/image} library provides easy-to-use functions
|
||||||
for constructing images, and DrRacket can display an image result as
|
for constructing images, and DrRacket can display an image result as
|
||||||
easily as it can display a number result. In this case, a
|
easily as it can display a number result. In this case, a
|
||||||
|
|
Loading…
Reference in New Issue
Block a user