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" ; -----------------------------------------------
|
||||
@code{#lang racket
|
||||
;; Finds Racket sources in all subdirs
|
||||
(for ([path (in-directory)])
|
||||
(when (regexp-match? #rx"[.]rkt$" path)
|
||||
(printf "source file: ~a\n" path)))}
|
||||
(for ([path (in-directory)]
|
||||
#:when (regexp-match? #rx"[.]rkt$" path))
|
||||
(printf "source file: ~a\n" path))}
|
||||
@desc{The @elemcode{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 @elemcode{for} form binds
|
||||
|
@ -97,11 +97,11 @@
|
|||
(generic-example #:title "Unique Lines"; -----------------------------------------------
|
||||
@code{#lang racket
|
||||
;; Report each unique line from stdin
|
||||
(let ([saw (make-hash)])
|
||||
(define seen (make-hash))
|
||||
(for ([line (in-lines)])
|
||||
(unless (hash-ref saw line #f)
|
||||
(unless (hash-ref seen line #f)
|
||||
(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
|
||||
program in DrRacket, but it makes more sense from the command line.}))
|
||||
@; Additional examples: -------------------------------------------
|
||||
|
@ -110,10 +110,10 @@
|
|||
@code{#lang racket ; A picture
|
||||
(require 2htdp/image)
|
||||
(let sierpinski ([n 8])
|
||||
(if (zero? n)
|
||||
(triangle 2 'solid 'red)
|
||||
(let ([t (sierpinski (- n 1))])
|
||||
(freeze (above t (beside t t))))))}
|
||||
(cond
|
||||
[(zero? n) (triangle 2 'solid 'red)]
|
||||
[else (define t (sierpinski (- n 1)))
|
||||
(freeze (above t (beside t t)))]))}
|
||||
@desc{The @elemcode{2htdp/image} library provides easy-to-use functions
|
||||
for constructing images, and DrRacket can display an image result as
|
||||
easily as it can display a number result. In this case, a
|
||||
|
|
Loading…
Reference in New Issue
Block a user