[Style] racketmod0, space issues
This commit is contained in:
parent
e3408c197d
commit
9999a02009
|
@ -51,7 +51,7 @@ for the last one, definitional constructs increase the indentation level.
|
||||||
Therefore, favor @scheme[define] when feasible.
|
Therefore, favor @scheme[define] when feasible.
|
||||||
|
|
||||||
@compare[
|
@compare[
|
||||||
@racketmod[#:file
|
@racketmod0[#:file
|
||||||
@tt{good}
|
@tt{good}
|
||||||
racket
|
racket
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ racket
|
||||||
(set-box! y t))
|
(set-box! y t))
|
||||||
]
|
]
|
||||||
@; -----------------------------------------------------------------------------
|
@; -----------------------------------------------------------------------------
|
||||||
@racketmod[#:file
|
@racketmod0[#:file
|
||||||
@tt{bad}
|
@tt{bad}
|
||||||
racket
|
racket
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ racket
|
||||||
series of @racket[define]s because the former has @emph{sequential} scope
|
series of @racket[define]s because the former has @emph{sequential} scope
|
||||||
and the latter has @emph{mutually recursive} scope.
|
and the latter has @emph{mutually recursive} scope.
|
||||||
@compare[
|
@compare[
|
||||||
@racketmod[#:file
|
@racketmod0[#:file
|
||||||
@tt{works}
|
@tt{works}
|
||||||
racket
|
racket
|
||||||
(define (print-two f)
|
(define (print-two f)
|
||||||
|
@ -88,7 +88,7 @@ racket
|
||||||
f))
|
f))
|
||||||
]
|
]
|
||||||
@; -----------------------------------------------------------------------------
|
@; -----------------------------------------------------------------------------
|
||||||
@racketmod[#:file
|
@racketmod0[#:file
|
||||||
|
|
||||||
@tt{does @bold{not}}
|
@tt{does @bold{not}}
|
||||||
racket
|
racket
|
||||||
|
@ -112,7 +112,7 @@ too. Because @scheme[cond] and its relatives (@scheme[case],
|
||||||
prefer them over @scheme[if].
|
prefer them over @scheme[if].
|
||||||
|
|
||||||
@compare[
|
@compare[
|
||||||
@racketmod[#:file
|
@racketmod0[#:file
|
||||||
@tt{good}
|
@tt{good}
|
||||||
racket
|
racket
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ racket
|
||||||
(rate f)
|
(rate f)
|
||||||
(curved (g r)))])
|
(curved (g r)))])
|
||||||
]
|
]
|
||||||
@racketmod[#:file
|
@racketmod0[#:file
|
||||||
@tt{bad}
|
@tt{bad}
|
||||||
racket
|
racket
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ Don't nest expressions too deeply. Instead name intermediate results. With
|
||||||
well-chosen names your expression becomes easy to read.
|
well-chosen names your expression becomes easy to read.
|
||||||
|
|
||||||
@compare[
|
@compare[
|
||||||
@racketmod[#:file
|
@racketmod0[#:file
|
||||||
@tt{good}
|
@tt{good}
|
||||||
racket
|
racket
|
||||||
(define (next-month date)
|
(define (next-month date)
|
||||||
|
@ -168,7 +168,7 @@ racket
|
||||||
`(,day ,(+ month 1))))
|
`(,day ,(+ month 1))))
|
||||||
]
|
]
|
||||||
@; -----------------------------------------------------------------------------
|
@; -----------------------------------------------------------------------------
|
||||||
@racketmod[#:file
|
@racketmod0[#:file
|
||||||
@tt{bad}
|
@tt{bad}
|
||||||
racket
|
racket
|
||||||
(define (next-month d)
|
(define (next-month d)
|
||||||
|
@ -202,7 +202,7 @@ functions have names that tell you what they compute and that help
|
||||||
accelerate reading.
|
accelerate reading.
|
||||||
|
|
||||||
@compare[
|
@compare[
|
||||||
@racketmod[#:file
|
@racketmod0[#:file
|
||||||
@tt{good}
|
@tt{good}
|
||||||
racket
|
racket
|
||||||
|
|
||||||
|
@ -213,7 +213,7 @@ racket
|
||||||
(to-list f)))
|
(to-list f)))
|
||||||
]
|
]
|
||||||
@; -----------------------------------------------------------------------------
|
@; -----------------------------------------------------------------------------
|
||||||
@racketmod[#:file
|
@racketmod0[#:file
|
||||||
@tt{bad}
|
@tt{bad}
|
||||||
racket
|
racket
|
||||||
|
|
||||||
|
@ -226,7 +226,7 @@ racket
|
||||||
|
|
||||||
Even a curried function does not need @racket[lambda].
|
Even a curried function does not need @racket[lambda].
|
||||||
@compare[
|
@compare[
|
||||||
@racketmod[#:file
|
@racketmod0[#:file
|
||||||
@tt{good}
|
@tt{good}
|
||||||
racket
|
racket
|
||||||
|
|
||||||
|
@ -234,7 +234,7 @@ racket
|
||||||
...)
|
...)
|
||||||
]
|
]
|
||||||
@; -----------------------------------------------------------------------------
|
@; -----------------------------------------------------------------------------
|
||||||
@racketmod[#:file
|
@racketmod0[#:file
|
||||||
@tt{acceptable}
|
@tt{acceptable}
|
||||||
racket
|
racket
|
||||||
|
|
||||||
|
@ -277,7 +277,7 @@ With the availability of @racket[for/fold], @racket[for/list],
|
||||||
@;%
|
@;%
|
||||||
@(begin
|
@(begin
|
||||||
#reader scribble/comment-reader
|
#reader scribble/comment-reader
|
||||||
[racketmod #:file
|
[racketmod0 #:file
|
||||||
@tt{good}
|
@tt{good}
|
||||||
racket
|
racket
|
||||||
|
|
||||||
|
@ -297,7 +297,7 @@ racket
|
||||||
@;%
|
@;%
|
||||||
@(begin
|
@(begin
|
||||||
#reader scribble/comment-reader
|
#reader scribble/comment-reader
|
||||||
[racketmod #:file
|
[racketmod0 #:file
|
||||||
@tt{bad}
|
@tt{bad}
|
||||||
racket
|
racket
|
||||||
|
|
||||||
|
@ -330,7 +330,7 @@ Define functions when possible, Or, do not introduce macros when functions
|
||||||
will do.
|
will do.
|
||||||
|
|
||||||
@compare[
|
@compare[
|
||||||
@racketmod[#:file
|
@racketmod0[#:file
|
||||||
@tt{good}
|
@tt{good}
|
||||||
racket
|
racket
|
||||||
...
|
...
|
||||||
|
@ -341,7 +341,7 @@ racket
|
||||||
@; -----------------------------------------------------------------------------
|
@; -----------------------------------------------------------------------------
|
||||||
@(begin
|
@(begin
|
||||||
#reader scribble/comment-reader
|
#reader scribble/comment-reader
|
||||||
[racketmod #:file
|
[racketmod0 #:file
|
||||||
@tt{bad}
|
@tt{bad}
|
||||||
racket
|
racket
|
||||||
...
|
...
|
||||||
|
@ -362,42 +362,46 @@ When you handle exceptions, specify the exception as precisely as
|
||||||
possible.
|
possible.
|
||||||
|
|
||||||
@compare[
|
@compare[
|
||||||
@racketmod[#:file
|
@racketmod0[#:file
|
||||||
@tt{good}
|
@tt{good}
|
||||||
racket
|
racket
|
||||||
...
|
...
|
||||||
;; String [X -> Y] String -> Void
|
(code:comment #, @t{FN [X -> Y] FN -> Void})
|
||||||
(define (convert in f out)
|
(define (convert in f out)
|
||||||
(with-handlers
|
(with-handlers
|
||||||
((exn:fail:read? X))
|
((exn:fail:read? X))
|
||||||
(with-output-to out
|
(with-output-to out
|
||||||
(lambda ()
|
(writer f))))
|
||||||
(with-input-from in
|
|
||||||
(reader f))))))
|
|
||||||
|
|
||||||
;; may raise exn:fail:read
|
(code:comment #, @t{may raise exn:fail:read})
|
||||||
(define (reader f) ...)
|
(define ((writer f))
|
||||||
|
(with-input-from in
|
||||||
|
(reader f)))
|
||||||
|
|
||||||
(define (X an-exn) ...)
|
(code:comment #, @t{may raise exn:fail:read})
|
||||||
|
(define ((reader f))
|
||||||
|
... f ...)
|
||||||
]
|
]
|
||||||
@; -----------------------------------------------------------------------------
|
@; -----------------------------------------------------------------------------
|
||||||
@racketmod[#:file
|
@racketmod0[#:file
|
||||||
@tt{bad}
|
@tt{bad}
|
||||||
racket
|
racket
|
||||||
...
|
...
|
||||||
;; String [X -> Y] String -> Void
|
(code:comment #, @t{FN [X -> Y] FN -> Void})
|
||||||
(define (convert in f out)
|
(define (convert in f out)
|
||||||
(with-handlers
|
(with-handlers
|
||||||
(((code:hilite (lambda _ #t)) X))
|
(((code:hilite (lambda _ #t)) X))
|
||||||
(with-output-to out
|
(with-output-to out
|
||||||
(lambda ()
|
(writer f))))
|
||||||
(with-input-from in
|
|
||||||
(reader f))))))
|
|
||||||
|
|
||||||
;; may raise exn:fail:read
|
(code:comment #, @t{may raise exn:fail:read})
|
||||||
(define (reader f) ...)
|
(define ((writer f))
|
||||||
|
(with-input-from in
|
||||||
|
(reader f)))
|
||||||
|
|
||||||
(define (X an-exn) ...)
|
(code:comment #, @t{may raise exn:fail:read})
|
||||||
|
(define ((reader f))
|
||||||
|
... f ...)
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
Using @racket[(lambda _ #t)] as an exception predicate suggests to the
|
Using @racket[(lambda _ #t)] as an exception predicate suggests to the
|
||||||
|
@ -410,41 +414,45 @@ It is equally bad to use @racket[exn?] as the exception predicate even if
|
||||||
exceptions, too. To catch all failures, use @racket[exn:fail?] as shown on
|
exceptions, too. To catch all failures, use @racket[exn:fail?] as shown on
|
||||||
the left:
|
the left:
|
||||||
@compare[
|
@compare[
|
||||||
@racketmod[#:file
|
@racketmod0[#:file
|
||||||
@tt{good}
|
@tt{good}
|
||||||
racket
|
racket
|
||||||
...
|
...
|
||||||
;; String [X -> Y] String -> Void
|
(code:comment #, @t{FN [X -> Y] FN -> Void})
|
||||||
(define (convert in f out)
|
(define (convert in f out)
|
||||||
(with-handlers
|
(with-handlers
|
||||||
((exn:fail? X))
|
((exn:fail? X))
|
||||||
(with-output-to out
|
(with-output-to out
|
||||||
(lambda ()
|
(writer f))))
|
||||||
(with-input-from in
|
|
||||||
(reader f))))))
|
|
||||||
|
|
||||||
;; may raise exn:fail:read
|
(code:comment #, @t{may raise exn:fail:read})
|
||||||
(define (reader f) ...)
|
(define ((writer f))
|
||||||
|
(with-input-from in
|
||||||
|
(reader f)))
|
||||||
|
|
||||||
(define (X an-exn) ...)
|
(code:comment #, @t{may raise exn:fail:read})
|
||||||
|
(define ((reader f))
|
||||||
|
... f ...)
|
||||||
]
|
]
|
||||||
@racketmod[#:file
|
@racketmod0[#:file
|
||||||
@tt{bad}
|
@tt{bad}
|
||||||
racket
|
racket
|
||||||
...
|
...
|
||||||
;; String [X -> Y] String -> Void
|
(code:comment #, @t{FN [X -> Y] FN -> Void})
|
||||||
(define (convert in f out)
|
(define (convert in f out)
|
||||||
(with-handlers
|
(with-handlers
|
||||||
(((code:hilite exn?) X))
|
(((code:hilite exn?) X))
|
||||||
(with-output-to out
|
(with-output-to out
|
||||||
(lambda ()
|
(writer f))))
|
||||||
(with-input-from in
|
|
||||||
(reader f))))))
|
|
||||||
|
|
||||||
;; may raise exn:fail:read
|
(code:comment #, @t{may raise exn:fail:read})
|
||||||
(define (reader f) ...)
|
(define ((writer f))
|
||||||
|
(with-input-from in
|
||||||
|
(reader f)))
|
||||||
|
|
||||||
(define (X an-exn) ...)
|
(code:comment #, @t{may raise exn:fail:read})
|
||||||
|
(define ((reader f))
|
||||||
|
... f ...)
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -452,24 +460,31 @@ Finally, a handler for a @racket[exn:fail?] clause should never
|
||||||
succeed for all possible failures because it silences all kinds of
|
succeed for all possible failures because it silences all kinds of
|
||||||
exceptions that you probably want to see:
|
exceptions that you probably want to see:
|
||||||
@codebox[
|
@codebox[
|
||||||
@racketmod[#:file
|
@racketmod0[#:file
|
||||||
@tt{bad}
|
@tt{bad}
|
||||||
racket
|
racket
|
||||||
...
|
...
|
||||||
;; String [X -> Y] String -> Void
|
(code:comment #, @t{FN [X -> Y] FN -> Void})
|
||||||
(define (convert in f out)
|
(define (convert in f out)
|
||||||
(with-handlers ((exn:fail? (lambda (e)
|
(with-handlers ((exn:fail? handler))
|
||||||
(cond
|
|
||||||
[(exn:fail:read? e)
|
|
||||||
(displayln "drracket is special")]
|
|
||||||
[else (void)]))))
|
|
||||||
(with-output-to out
|
(with-output-to out
|
||||||
(lambda ()
|
(writer f))))
|
||||||
(with-input-from in
|
|
||||||
(reader f))))))
|
|
||||||
|
|
||||||
;; may raise exn:fail:read
|
(code:comment #, @t{Exn -> Void})
|
||||||
(define (reader f) ...)
|
(define (handler e)
|
||||||
|
(cond
|
||||||
|
[(exn:fail:read? e)
|
||||||
|
(displayln "drracket is special")]
|
||||||
|
[else (void)]))
|
||||||
|
|
||||||
|
(code:comment #, @t{may raise exn:fail:read})
|
||||||
|
(define ((writer f))
|
||||||
|
(with-input-from in
|
||||||
|
(reader f)))
|
||||||
|
|
||||||
|
(code:comment #, @t{may raise exn:fail:read})
|
||||||
|
(define ((reader f))
|
||||||
|
... f ...)
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
If you wish to deal with several different kind of failures, say
|
If you wish to deal with several different kind of failures, say
|
||||||
|
@ -483,30 +498,34 @@ racket
|
||||||
If you need to set a parameter, use @racket[parameterize]:
|
If you need to set a parameter, use @racket[parameterize]:
|
||||||
|
|
||||||
@compare[
|
@compare[
|
||||||
@racketmod[#:file
|
@racketmod0[#:file
|
||||||
@tt{good}
|
@tt{good}
|
||||||
racket
|
racket
|
||||||
...
|
...
|
||||||
;; String OutputPort -> Void
|
(define cop
|
||||||
(define (send-to msg op)
|
current-output-port)
|
||||||
(parameterize
|
|
||||||
((current-output-port op))
|
(code:comment #, @t{String OPort -> Void})
|
||||||
(format-and-display msg))
|
(define (send msg op)
|
||||||
(record-message-in-log msg))
|
(parameterize ((cop op))
|
||||||
|
(display msg))
|
||||||
|
(record msg))
|
||||||
]
|
]
|
||||||
@; -----------------------------------------------------------------------------
|
@; -----------------------------------------------------------------------------
|
||||||
@racketmod[#:file
|
@racketmod0[#:file
|
||||||
@tt{bad}
|
@tt{bad}
|
||||||
racket
|
racket
|
||||||
...
|
...
|
||||||
;; String OutputPort -> Void
|
(define cop
|
||||||
(define (send-to msg op)
|
current-output-port)
|
||||||
(define cp
|
|
||||||
(current-output-port))
|
(code:comment #, @t{String OPort -> Void})
|
||||||
(current-output-port op)
|
(define (send msg op)
|
||||||
(format-and-display msg)
|
(define cp (cop))
|
||||||
(current-output-port cp)
|
(cop op)
|
||||||
(record-message-in-log msg))
|
(display msg)
|
||||||
|
(cop cp)
|
||||||
|
(record msg))
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -60,11 +60,11 @@
|
||||||
|
|
||||||
(define (sty columns width)
|
(define (sty columns width)
|
||||||
(define space
|
(define space
|
||||||
(style #f `(,(attributes `((width . ,(format "~a" width)) (align . "center") (valign . "top"))))))
|
(style #f `(,(attributes `((width . ,(format "~a" width)) (align . "left") (valign . "top"))))))
|
||||||
;; -- in --
|
;; -- in --
|
||||||
(style #f
|
(style #f
|
||||||
(list
|
(list
|
||||||
(attributes '((border . "1") (cellpadding . "10")))
|
(attributes '((border . "1") (cellpadding . "1")))
|
||||||
(table-columns (make-list columns space)))))
|
(table-columns (make-list columns space)))))
|
||||||
|
|
||||||
;; ===================================================================================================
|
;; ===================================================================================================
|
||||||
|
|
|
@ -36,11 +36,11 @@ When you design your own macro with a large expansion, try to factor it
|
||||||
into a function call that consumes small thunks or procedures.
|
into a function call that consumes small thunks or procedures.
|
||||||
|
|
||||||
@compare[
|
@compare[
|
||||||
@racketmod[#:file
|
@racketmod0[#:file
|
||||||
@tt{good}
|
@tt{good}
|
||||||
racket
|
racket
|
||||||
...
|
...
|
||||||
(define-syntax (search->run s)
|
(define-syntax (search s)
|
||||||
(syntax-parse s
|
(syntax-parse s
|
||||||
[(_ x (e:expr ...)
|
[(_ x (e:expr ...)
|
||||||
(~datum in)
|
(~datum in)
|
||||||
|
@ -60,11 +60,11 @@ racket
|
||||||
@; -----------------------------------------------------------------------------
|
@; -----------------------------------------------------------------------------
|
||||||
@(begin
|
@(begin
|
||||||
#reader scribble/comment-reader
|
#reader scribble/comment-reader
|
||||||
[racketmod #:file
|
[racketmod0 #:file
|
||||||
@tt{bad}
|
@tt{bad}
|
||||||
racket
|
racket
|
||||||
...
|
...
|
||||||
(define-syntax (search->run s)
|
(define-syntax (search s)
|
||||||
(syntax-parse s
|
(syntax-parse s
|
||||||
[(_ x (e:expr ...)
|
[(_ x (e:expr ...)
|
||||||
(~datum in)
|
(~datum in)
|
||||||
|
|
|
@ -306,7 +306,7 @@ Another widely used convention is to @emph{prefix} a function name with the data
|
||||||
@tt{good}
|
@tt{good}
|
||||||
racket
|
racket
|
||||||
|
|
||||||
board-free-spaces board-attackable-spaces board-serialize
|
board-free-spaces board-closed-spaces board-serialize
|
||||||
])]
|
])]
|
||||||
In contrast, variables use a @emph{suffix} that indicates their type:
|
In contrast, variables use a @emph{suffix} that indicates their type:
|
||||||
@codebox[
|
@codebox[
|
||||||
|
|
|
@ -70,7 +70,7 @@ implementation:
|
||||||
@codebox[
|
@codebox[
|
||||||
@(begin
|
@(begin
|
||||||
#reader scribble/comment-reader
|
#reader scribble/comment-reader
|
||||||
(racketmod #:file
|
(racketmod0 #:file
|
||||||
@tt{good}
|
@tt{good}
|
||||||
racket/base
|
racket/base
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ If you choose to use @racket[provide/contract], define auxiliary concepts
|
||||||
@codebox[
|
@codebox[
|
||||||
@(begin
|
@(begin
|
||||||
#reader scribble/comment-reader
|
#reader scribble/comment-reader
|
||||||
(racketmod #:file
|
(racketmod0 #:file
|
||||||
@tt{good}
|
@tt{good}
|
||||||
racket/base
|
racket/base
|
||||||
|
|
||||||
|
@ -115,9 +115,9 @@ If you choose to use @racket[provide/contract], define auxiliary concepts
|
||||||
(flat-named-contract "placement" ...))
|
(flat-named-contract "placement" ...))
|
||||||
|
|
||||||
(provide/contract
|
(provide/contract
|
||||||
;; initialize the game board for the specified number of players
|
;; initialize the board for the given number of players
|
||||||
[board-init (-> player#/c plain-board/c)]
|
[board-init (-> player#/c plain-board/c)]
|
||||||
;; initialize a board for some players and place the specified tiles
|
;; initialize a board and place the tiles
|
||||||
[create-board (-> player#/c (listof placement/c)
|
[create-board (-> player#/c (listof placement/c)
|
||||||
(or/c plain-board/c string?))]
|
(or/c plain-board/c string?))]
|
||||||
;; create a board from an X-expression representation
|
;; create a board from an X-expression representation
|
||||||
|
@ -164,7 +164,7 @@ This helps people find the relevant information quickly.
|
||||||
@;%
|
@;%
|
||||||
@(begin
|
@(begin
|
||||||
#reader scribble/comment-reader
|
#reader scribble/comment-reader
|
||||||
(racketmod #:file
|
(racketmod0 #:file
|
||||||
@tt{good}
|
@tt{good}
|
||||||
racket
|
racket
|
||||||
|
|
||||||
|
@ -197,7 +197,7 @@ This helps people find the relevant information quickly.
|
||||||
|
|
||||||
@(begin
|
@(begin
|
||||||
#reader scribble/comment-reader
|
#reader scribble/comment-reader
|
||||||
(racketmod #:file
|
(racketmod0 #:file
|
||||||
@tt{bad}
|
@tt{bad}
|
||||||
racket
|
racket
|
||||||
|
|
||||||
|
@ -245,7 +245,7 @@ should come with a description of the grammar clause it introduces
|
||||||
@codebox[
|
@codebox[
|
||||||
@(begin
|
@(begin
|
||||||
#reader scribble/comment-reader
|
#reader scribble/comment-reader
|
||||||
(racketmod #:file
|
(racketmod0 #:file
|
||||||
@tt{good}
|
@tt{good}
|
||||||
racket
|
racket
|
||||||
|
|
||||||
|
@ -254,10 +254,10 @@ racket
|
||||||
;; action:definition-or-expression)
|
;; action:definition-or-expression)
|
||||||
;;
|
;;
|
||||||
;; (define-strategy (s board tiles available score) ...)
|
;; (define-strategy (s board tiles available score) ...)
|
||||||
;; defines a function from an instance of player to a placement
|
;; defines a function from an instance of player to a
|
||||||
;; The four identifier denote the state of the board,
|
;; placement. The four identifier denote the state of
|
||||||
;; the player's hand, the places where a tile can be
|
;; the board, the player's hand, the places where a
|
||||||
;; placed, and the player's current score.
|
;; tile can be placed, and the player's current score.
|
||||||
define-strategy)
|
define-strategy)
|
||||||
))]
|
))]
|
||||||
|
|
||||||
|
@ -312,7 +312,7 @@ As of version 5.3, Racket supports sub-modules. Use sub-modules to
|
||||||
@codebox[
|
@codebox[
|
||||||
@(begin
|
@(begin
|
||||||
#reader scribble/comment-reader
|
#reader scribble/comment-reader
|
||||||
(racketmod #:file
|
(racketmod0 #:file
|
||||||
@tt{fahrenheit.rkt}
|
@tt{fahrenheit.rkt}
|
||||||
racket
|
racket
|
||||||
|
|
||||||
|
@ -394,7 +394,7 @@ constants and one for a function.
|
||||||
@codebox[
|
@codebox[
|
||||||
@(begin
|
@(begin
|
||||||
#reader scribble/comment-reader
|
#reader scribble/comment-reader
|
||||||
(racketmod #:file
|
(racketmod0 #:file
|
||||||
@tt{celsius.rkt}
|
@tt{celsius.rkt}
|
||||||
racket
|
racket
|
||||||
|
|
||||||
|
@ -402,6 +402,7 @@ constants and one for a function.
|
||||||
(define/contract AbsoluteF real? -459.67)
|
(define/contract AbsoluteF real? -459.67)
|
||||||
|
|
||||||
(define/contract (celsius->fahrenheit c)
|
(define/contract (celsius->fahrenheit c)
|
||||||
|
(code:comment #, @t{convert a celsius temperature to a fahrenheit temperature})
|
||||||
(-> (and/c real? (>=/c AbsoluteC))
|
(-> (and/c real? (>=/c AbsoluteC))
|
||||||
(and/c real? (>=/c AbsoluteF)))
|
(and/c real? (>=/c AbsoluteF)))
|
||||||
;; -- IN --
|
;; -- IN --
|
||||||
|
@ -453,7 +454,7 @@ contracts. Any value flow within the submodule is free of any constraints.
|
||||||
@codebox[
|
@codebox[
|
||||||
@(begin
|
@(begin
|
||||||
#reader scribble/comment-reader
|
#reader scribble/comment-reader
|
||||||
(racketmod #:file
|
(racketmod0 #:file
|
||||||
@tt{graph-traversal.rkt}
|
@tt{graph-traversal.rkt}
|
||||||
racket
|
racket
|
||||||
...
|
...
|
||||||
|
|
Loading…
Reference in New Issue
Block a user