Newlines at EOFs.
This commit is contained in:
parent
95679bdab5
commit
14d8c8b5a5
|
@ -21,14 +21,14 @@ Binary heaps are a simple implementation of priority queues.
|
|||
Makes a new empty heap using @racket[<=?] to order elements.
|
||||
|
||||
@examples[#:eval the-eval
|
||||
(define a-heap-of-strings (make-heap string<=?))
|
||||
a-heap-of-strings
|
||||
@code:comment{With structs:}
|
||||
(struct node (name val))
|
||||
(define (node<=? x y)
|
||||
(<= (node-val x) (node-val y)))
|
||||
(define a-heap-of-nodes (make-heap node<=?))
|
||||
a-heap-of-nodes]
|
||||
(define a-heap-of-strings (make-heap string<=?))
|
||||
a-heap-of-strings
|
||||
@code:comment{With structs:}
|
||||
(struct node (name val))
|
||||
(define (node<=? x y)
|
||||
(<= (node-val x) (node-val y)))
|
||||
(define a-heap-of-nodes (make-heap node<=?))
|
||||
a-heap-of-nodes]
|
||||
}
|
||||
|
||||
@defproc[(heap? [x any/c]) boolean?]{
|
||||
|
@ -36,17 +36,17 @@ a-heap-of-nodes]
|
|||
Returns @racket[#t] if @racket[x] is a heap, @racket[#f] otherwise.
|
||||
|
||||
@examples[#:eval the-eval
|
||||
(heap? (make-heap <=))
|
||||
(heap? "I am not a heap")]
|
||||
(heap? (make-heap <=))
|
||||
(heap? "I am not a heap")]
|
||||
}
|
||||
|
||||
@defproc[(heap-count [h heap?]) exact-nonnegative-integer?]{
|
||||
|
||||
Returns the number of elements in the heap.
|
||||
@examples[#:eval the-eval
|
||||
(define a-heap (make-heap <=))
|
||||
(heap-add-all! a-heap '(7 3 9 1 13 21 15 31))
|
||||
(heap-count a-heap)
|
||||
(define a-heap (make-heap <=))
|
||||
(heap-add-all! a-heap '(7 3 9 1 13 21 15 31))
|
||||
(heap-count a-heap)
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -55,8 +55,8 @@ Returns the number of elements in the heap.
|
|||
Adds each @racket[v] to the heap.
|
||||
|
||||
@examples[#:eval the-eval
|
||||
(define a-heap (make-heap <=))
|
||||
(heap-add! a-heap 2009 1009)]
|
||||
(define a-heap (make-heap <=))
|
||||
(heap-add! a-heap 2009 1009)]
|
||||
}
|
||||
|
||||
|
||||
|
@ -66,14 +66,14 @@ Adds each element contained in @racket[v] to the heap, leaving
|
|||
@racket[v] unchanged.
|
||||
|
||||
@examples[#:eval the-eval
|
||||
(define heap-1 (make-heap <=))
|
||||
(define heap-2 (make-heap <=))
|
||||
(define heap-12 (make-heap <=))
|
||||
(heap-add-all! heap-1 '(3 1 4 1 5 9 2 6))
|
||||
(heap-add-all! heap-2 #(2 7 1 8 2 8 1 8))
|
||||
(heap-add-all! heap-12 heap-1)
|
||||
(heap-add-all! heap-12 heap-2)
|
||||
(heap-count heap-12)]
|
||||
(define heap-1 (make-heap <=))
|
||||
(define heap-2 (make-heap <=))
|
||||
(define heap-12 (make-heap <=))
|
||||
(heap-add-all! heap-1 '(3 1 4 1 5 9 2 6))
|
||||
(heap-add-all! heap-2 #(2 7 1 8 2 8 1 8))
|
||||
(heap-add-all! heap-12 heap-1)
|
||||
(heap-add-all! heap-12 heap-2)
|
||||
(heap-count heap-12)]
|
||||
}
|
||||
|
||||
@defproc[(heap-min [h heap?]) any/c]{
|
||||
|
@ -82,13 +82,13 @@ Returns the least element in the heap @racket[h], according to the
|
|||
heap's ordering. If the heap is empty, an exception is raised.
|
||||
|
||||
@examples[#:eval the-eval
|
||||
(define a-heap (make-heap string<=?))
|
||||
(heap-add! a-heap "sneezy" "sleepy" "dopey" "doc"
|
||||
"happy" "bashful" "grumpy")
|
||||
(heap-min a-heap)
|
||||
(define a-heap (make-heap string<=?))
|
||||
(heap-add! a-heap "sneezy" "sleepy" "dopey" "doc"
|
||||
"happy" "bashful" "grumpy")
|
||||
(heap-min a-heap)
|
||||
|
||||
@code:comment{Taking the min of the empty heap is an error:}
|
||||
(heap-min (make-heap <=))
|
||||
@code:comment{Taking the min of the empty heap is an error:}
|
||||
(heap-min (make-heap <=))
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -98,13 +98,13 @@ Removes the least element in the heap @racket[h]. If the heap is
|
|||
empty, an exception is raised.
|
||||
|
||||
@examples[#:eval the-eval
|
||||
(define a-heap (make-heap string<=?))
|
||||
(heap-add! a-heap "fili" "fili" "oin" "gloin" "thorin"
|
||||
"dwalin" "balin" "bifur" "bofur"
|
||||
"bombur" "dori" "nori" "ori")
|
||||
(heap-min a-heap)
|
||||
(heap-remove-min! a-heap)
|
||||
(heap-min a-heap)]
|
||||
(define a-heap (make-heap string<=?))
|
||||
(heap-add! a-heap "fili" "fili" "oin" "gloin" "thorin"
|
||||
"dwalin" "balin" "bifur" "bofur"
|
||||
"bombur" "dori" "nori" "ori")
|
||||
(heap-min a-heap)
|
||||
(heap-remove-min! a-heap)
|
||||
(heap-min a-heap)]
|
||||
}
|
||||
|
||||
@defproc[(vector->heap [<=? (-> any/c any/c any/c)] [items vector?]) heap?]{
|
||||
|
@ -112,12 +112,12 @@ empty, an exception is raised.
|
|||
Builds a heap with the elements from @racket[items]. The vector is not
|
||||
modified.
|
||||
@examples[#:eval the-eval
|
||||
(struct item (val frequency))
|
||||
(define (item<=? x y)
|
||||
(<= (item-frequency x) (item-frequency y)))
|
||||
(define some-sample-items
|
||||
(vector (item #\a 17) (item #\b 12) (item #\c 19)))
|
||||
(define a-heap (vector->heap item<=? some-sample-items))
|
||||
(struct item (val frequency))
|
||||
(define (item<=? x y)
|
||||
(<= (item-frequency x) (item-frequency y)))
|
||||
(define some-sample-items
|
||||
(vector (item #\a 17) (item #\b 12) (item #\c 19)))
|
||||
(define a-heap (vector->heap item<=? some-sample-items))
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -127,9 +127,9 @@ Returns a vector containing the elements of heap @racket[h] in the
|
|||
heap's order. The heap is not modified.
|
||||
|
||||
@examples[#:eval the-eval
|
||||
(define word-heap (make-heap string<=?))
|
||||
(heap-add! word-heap "pile" "mound" "agglomerate" "cumulation")
|
||||
(heap->vector word-heap)
|
||||
(define word-heap (make-heap string<=?))
|
||||
(heap-add! word-heap "pile" "mound" "agglomerate" "cumulation")
|
||||
(heap->vector word-heap)
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -137,12 +137,12 @@ heap's order. The heap is not modified.
|
|||
|
||||
Makes a copy of heap @racket[h].
|
||||
@examples[#:eval the-eval
|
||||
(define word-heap (make-heap string<=?))
|
||||
(heap-add! word-heap "pile" "mound" "agglomerate" "cumulation")
|
||||
(define a-copy (heap-copy word-heap))
|
||||
(heap-remove-min! a-copy)
|
||||
(heap-count word-heap)
|
||||
(heap-count a-copy)
|
||||
(define word-heap (make-heap string<=?))
|
||||
(heap-add! word-heap "pile" "mound" "agglomerate" "cumulation")
|
||||
(define a-copy (heap-copy word-heap))
|
||||
(heap-remove-min! a-copy)
|
||||
(heap-count word-heap)
|
||||
(heap-count a-copy)
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -154,14 +154,13 @@ Makes a copy of heap @racket[h].
|
|||
Sorts vector @racket[v] using the comparison function @racket[<=?].
|
||||
|
||||
@examples[#:eval the-eval
|
||||
(define terms (vector "batch" "deal" "flock" "good deal" "hatful" "lot"))
|
||||
(heap-sort! string<=? terms)
|
||||
terms
|
||||
(define terms (vector "batch" "deal" "flock" "good deal" "hatful" "lot"))
|
||||
(heap-sort! string<=? terms)
|
||||
terms
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
|
||||
@defproc[(in-heap/consume! [heap heap?]) sequence?]{
|
||||
Returns a sequence equivalent to @racket[heap], maintaining the heap's ordering.
|
||||
The heap is consumed in the process. Equivalent to repeated calling
|
||||
|
@ -176,6 +175,7 @@ The heap is consumed in the process. Equivalent to repeated calling
|
|||
|
||||
(heap-count h)]
|
||||
}
|
||||
|
||||
@defproc[(in-heap [heap heap?]) sequence?]{
|
||||
Returns a sequence equivalent to @racket[heap], maintaining the heap's ordering.
|
||||
Equivalent to @racket[in-heap/consume!] except the heap is copied first.
|
||||
|
@ -190,4 +190,5 @@ Equivalent to @racket[in-heap/consume!] except the heap is copied first.
|
|||
(heap-count h)]
|
||||
}
|
||||
|
||||
|
||||
@close-eval[the-eval]
|
|
@ -168,4 +168,5 @@ Returns @racket[#t] if @racket[v] represents a position in an
|
|||
interval-map, @racket[#f] otherwise.
|
||||
}
|
||||
|
||||
|
||||
@close-eval[the-eval]
|
|
@ -96,5 +96,4 @@ Returns a sequence whose elements are the elements of
|
|||
}
|
||||
|
||||
|
||||
|
||||
@close-eval[qeval]
|
|
@ -22,5 +22,4 @@ that is the MD5 hash of the given input stream or byte string.
|
|||
]}
|
||||
|
||||
|
||||
|
||||
@close-eval[md5-eval]
|
|
@ -40,5 +40,4 @@ Returns the macro stepper logo.
|
|||
}
|
||||
|
||||
|
||||
|
||||
@close-eval[logos-eval]
|
|
@ -569,5 +569,4 @@ module path and the module paths of its immediate dependents.
|
|||
}
|
||||
|
||||
|
||||
|
||||
@close-eval[the-eval]
|
|
@ -95,5 +95,4 @@ running @racket[read-eval-print]. In addition, @racket[current-exit]
|
|||
is set to escape from the call to @racket[new-cafe].}
|
||||
|
||||
|
||||
|
||||
@close-eval[compat-eval]
|
|
@ -271,5 +271,4 @@ Creates a new hash-table providing the quoted flags (if any) to
|
|||
corresponding values.}
|
||||
|
||||
|
||||
|
||||
@close-eval[etc-eval]
|
|
@ -449,7 +449,4 @@ if the @racket[args] list is imbalanced, and the search stops at a
|
|||
non-keyword value.)}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@close-eval[kw-eval]
|
|
@ -67,6 +67,4 @@ Builds a function that accepts a structure type instance (matching
|
|||
structure type instance.}
|
||||
|
||||
|
||||
|
||||
|
||||
@close-eval[struct-eval]
|
|
@ -189,5 +189,4 @@ Imports nothing, exports @racket[cookie^].}
|
|||
Includes everything exported by the @racketmodname[net/cookie] module.
|
||||
|
||||
|
||||
|
||||
@close-eval[cookie-eval]
|
|
@ -243,5 +243,4 @@ Imports nothing, exports @racket[head^].}
|
|||
Includes everything exported by the @racketmodname[net/head] module.
|
||||
|
||||
|
||||
|
||||
@close-eval[head-eval]
|
|
@ -1459,5 +1459,4 @@ frozen structure in @racket[F].}
|
|||
]
|
||||
|
||||
|
||||
|
||||
@close-eval[racklog-eval]
|
|
@ -3100,7 +3100,4 @@ column-span of the new lw is always zero.
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@close-eval[redex-eval]
|
|
@ -1124,5 +1124,4 @@ is rendered as @racketblock[Γ ⊢ e : t]
|
|||
@generate-bibliography[]
|
||||
|
||||
|
||||
|
||||
@close-eval[amb-eval]
|
|
@ -344,6 +344,4 @@ Analogous to @racket[(unsafe!)], makes unsafe bindings of
|
|||
module.}
|
||||
|
||||
|
||||
|
||||
|
||||
@close-eval[objc-eval]
|
|
@ -479,5 +479,4 @@ annotates operations that can be inlined by the compiler (see
|
|||
decompiler can be used to help predict parallel performance.
|
||||
|
||||
|
||||
|
||||
@close-eval[future-eval]
|
|
@ -309,5 +309,4 @@ Returns @racket[(not v)].}
|
|||
}
|
||||
|
||||
|
||||
|
||||
@close-eval[bool-eval]
|
|
@ -202,6 +202,4 @@ allocated in the @tech{shared memory space}.
|
|||
@mz-examples[#:eval flfx-eval (make-shared-fxvector 4 3)]}
|
||||
|
||||
|
||||
|
||||
|
||||
@close-eval[flfx-eval]
|
|
@ -1,9 +1,9 @@
|
|||
#lang scribble/doc
|
||||
@(require "mz.rkt" (for-label racket/trace)
|
||||
scribble/eval)
|
||||
scribble/eval)
|
||||
|
||||
@(begin (define ev (make-base-eval))
|
||||
(ev '(require racket/trace)))
|
||||
(ev '(require racket/trace)))
|
||||
|
||||
@title{Tracing}
|
||||
|
||||
|
@ -80,7 +80,7 @@ trace information during the call, as described above in the docs for
|
|||
}
|
||||
|
||||
@defparam[current-trace-print-args trace-print-args
|
||||
(-> symbol?
|
||||
(-> symbol?
|
||||
list?
|
||||
(listof keyword?)
|
||||
list?
|
||||
|
@ -95,7 +95,7 @@ number indicating the depth of the call.
|
|||
}
|
||||
|
||||
@defparam[current-trace-print-results trace-print-results
|
||||
(-> symbol?
|
||||
(-> symbol?
|
||||
list?
|
||||
number?
|
||||
any)]{
|
||||
|
@ -124,6 +124,4 @@ results, and a number indicating the depth of the call.
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@close-eval[ev]
|
|
@ -275,5 +275,4 @@ A @techlink{check-procedure} that accepts syntax booleans.
|
|||
}
|
||||
|
||||
|
||||
|
||||
@close-eval[the-eval]
|
|
@ -60,6 +60,4 @@ refman]{module path index}; in this case, the
|
|||
contains the ``self'' index.}
|
||||
|
||||
|
||||
|
||||
|
||||
@close-eval[evaluator]
|
|
@ -84,4 +84,3 @@
|
|||
[lst (for/list ([x (in-heap/consume! h)]) x)])
|
||||
(heap-count h))
|
||||
0)
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#lang scribble/manual
|
||||
|
||||
@begin[(require (for-label (only-meta-in 0 typed/racket)) scribble/eval
|
||||
"../utils.rkt" (only-in "quick.scrbl" typed-mod))]
|
||||
"../utils.rkt" (only-in "quick.scrbl" typed-mod))]
|
||||
|
||||
@(define the-eval (make-base-eval))
|
||||
@(the-eval '(require typed/racket))
|
||||
|
@ -133,5 +133,4 @@ Typed Racket also attempts to detect more than one error in the module.
|
|||
}
|
||||
|
||||
|
||||
|
||||
@close-eval[the-eval]
|
|
@ -214,5 +214,4 @@ This module provides a macro for non-deterministic finite automata with epsilon
|
|||
@include-section["re.scrbl"]
|
||||
|
||||
|
||||
|
||||
@close-eval[our-eval]
|
|
@ -206,5 +206,4 @@ This module provides a few transformers that extend the syntax of regular expres
|
|||
(list 1 0)])]
|
||||
|
||||
|
||||
|
||||
@close-eval[our-eval]
|
|
@ -66,5 +66,4 @@ When attached to a struct type, automatically generates a printer using
|
|||
}
|
||||
|
||||
|
||||
|
||||
@close-eval[the-eval]
|
|
@ -155,5 +155,4 @@ listeners.
|
|||
}
|
||||
|
||||
|
||||
|
||||
@close-eval[the-eval]
|
|
@ -13,7 +13,7 @@ This module provides tools for logging.
|
|||
|
||||
@defproc[(with-logging-to-port
|
||||
[port output-port?] [proc (-> any)]
|
||||
[log-spec (or/c 'fatal 'error 'warning 'info 'debug symbol? #f)] ...)
|
||||
[log-spec (or/c 'fatal 'error 'warning 'info 'debug symbol? #f)] ...)
|
||||
any]{
|
||||
|
||||
Runs @racket[proc], outputting any logging that would be received by
|
||||
|
@ -35,8 +35,8 @@ Returns whatever @racket[proc] returns.
|
|||
[interceptor (-> (vector/c
|
||||
(or/c 'fatal 'error 'warning 'info 'debug)
|
||||
string?
|
||||
any/c)
|
||||
any)]
|
||||
any/c)
|
||||
any)]
|
||||
[proc (-> any)]
|
||||
[log-spec (or/c 'fatal 'error 'warning 'info 'debug symbol? #f)] ...)
|
||||
any]{
|
||||
|
@ -88,5 +88,4 @@ will then return a list of the log messages that have been reported.
|
|||
]}
|
||||
|
||||
|
||||
|
||||
@close-eval[the-eval]
|
|
@ -21,5 +21,4 @@ Note that these variables must have values accepted by
|
|||
}
|
||||
|
||||
|
||||
|
||||
@close-eval[the-eval]
|
|
@ -59,5 +59,4 @@ Corresponds to @racket[parameterize*], but can parameterize parameter groups as
|
|||
}
|
||||
|
||||
|
||||
|
||||
@close-eval[evaluator]
|
Loading…
Reference in New Issue
Block a user