svn: r150

This commit is contained in:
Jono Spiro 2004-08-06 11:58:00 +00:00
parent ffd45198fa
commit 050d9acd13
4 changed files with 33 additions and 23 deletions

View File

@ -3,10 +3,10 @@
(lib "match.ss")) (lib "match.ss"))
(define-mztake-process p (define-mztake-process p
("dijkstra.ss") ("dijkstra.ss")
("heap.ss" ("heap.ss"
[inserts 49 6 bind 'item] [inserts 49 6 bind 'item]
[removes 67 10 bind 'result])) [removes 67 10 bind 'result]))
(define (not-in-order e) (define (not-in-order e)
(filter-e (filter-e
@ -17,7 +17,7 @@
(history-e 2 e))) (history-e 2 e)))
(history-e 5 (history-e 2 (merge-e (removes . ==> . node-weight) (history-e 5 (history-e 2 (merge-e (removes . ==> . node-weight)
(inserts . -=> . 'reset)))) (inserts . -=> . 'reset))))
(define violations (define violations
(not-in-order (merge-e (removes . ==> . node-weight) (not-in-order (merge-e (removes . ==> . node-weight)
@ -37,4 +37,3 @@
(printf-b "model: ~a" model) (printf-b "model: ~a" model)
(start/resume p) (start/resume p)

View File

@ -9,11 +9,11 @@
and idea of why they recieve different values from the same "x". |# and idea of why they recieve different values from the same "x". |#
(define-mztake-process p ("first-class.ss" [x-before-let 3 29 bind 'x] (define-mztake-process p ("first-class.ss" [x-before-let 3 29 bind 'x]
[x-in-let 4 25 bind 'x] [x-in-let 4 25 bind 'x]
[x-after-let 5 11 bind 'x])) [x-after-let 5 11 bind 'x]))
(printf-b "Number of times x updates, should be 12: ~a" (printf-b "Number of times x updates, should be 12: ~a"
(count-e (merge-e x-before-let (count-b (merge-e x-before-let
x-in-let x-in-let
x-after-let))) x-after-let)))
#| merge-e takes multiple event streams and turns them into one event stream. #| merge-e takes multiple event streams and turns them into one event stream.

View File

@ -266,7 +266,7 @@ In more depth, the debugger works on a model roughly as follows:
This installs an ENTRY trace at the function entry point for This installs an ENTRY trace at the function entry point for
ALLOCATE-STACK and CLEAR-STACK in "my-stack.ss". Every time ALLOCATE-STACK and CLEAR-STACK in "my-stack.ss". Every time
those functions get called, these traces will send a "#t" event, those functions get called, these traces will send a "#t" event,
and could be counted using COUNT-E. and could be counted using COUNT-B.
* Once a MzTake processe is defined, and all the script code operating * Once a MzTake processe is defined, and all the script code operating
on traces is defined, START/RESUME can be called on the process on traces is defined, START/RESUME can be called on the process
@ -434,10 +434,16 @@ and can be used in the Interactions window.
_Useful Functions for Time-Varying Values_ _Useful Functions for Time-Varying Values_
Note: FrTime uss naming convention where functions which Note: FrTime uses a naming convention where functions which
return behaviors have names that end in "-b", and return behaviors have names that end in "-b", and
functions that return event streams end in "-e". functions that return event streams end in "-e".
Tips: When you have a behavior that you want to turn into
an event, use (changes behavior).
When you have an event that you want to be a
behavior, use (hold event)
MzTake defines a few functions on time-varying values MzTake defines a few functions on time-varying values
that are particularly useful when debugging: that are particularly useful when debugging:
@ -461,7 +467,7 @@ that are particularly useful when debugging:
Counts number of events seen on an eventstream. Counts number of events seen on an eventstream.
Often used directly on ENTRY traces, counting how many Often used directly on ENTRY traces, counting how many
times ENTRY occured: (count-e entry-trace) times ENTRY occured: (count-b entry-trace)
Also useful to count how many times a BIND changed Also useful to count how many times a BIND changed
by calling: (count-b (changes bind-trace)) by calling: (count-b (changes bind-trace))
@ -472,7 +478,7 @@ that are particularly useful when debugging:
Keeps track of the largest/smallest values seen on a stream. Keeps track of the largest/smallest values seen on a stream.
Use with BINDs: (largest-val-b (changes bind-trace)). Use with BINDs: (largest-val-b (changes bind-trace)).
> (sequence-match? seq evs) > (sequence-match? seq stream)
Matches a sequence of items in a list to the history Matches a sequence of items in a list to the history
of event pings, on the event stream evs. Returns #t of event pings, on the event stream evs. Returns #t

View File

@ -9,30 +9,35 @@
; Everything is contracted to 'any' for speed benefits, though there is already a big performance hit ; Everything is contracted to 'any' for speed benefits, though there is already a big performance hit
; Keeps a list of the last n values of a behavior ; Keeps a list of the last n values of a behavior
(define/contract history-b (case-> (event? . -> . any) (define/contract history-e (case-> (number? event? . -> . any)
(number? event? . -> . any)) (event? . -> . any))
(case-lambda [(stream) (case-lambda [(stream)
(define ((add-to-complete-hist x) hist) (append hist (list x))) (define ((add-to-complete-hist x) hist) (append hist (list x)))
(accum-b (stream . ==> . add-to-complete-hist) empty)] (accum-e (stream . ==> . add-to-complete-hist) empty)]
[(n stream) [(n stream)
(define ((add-to-short-hist x) hist) (append (if (< (length hist) n) hist (rest hist)) (list x))) (define ((add-to-short-hist x) hist) (append (if (< (length hist) n) hist (rest hist)) (list x)))
(accum-b (stream . ==> . add-to-short-hist) empty)])) (accum-e (stream . ==> . add-to-short-hist) empty)]))
(define/contract history-b (case-> (number? event? . -> . any)
(event? . -> . any))
(case-lambda [(stream) (hold (history-e stream) empty)]
[(n stream) (hold (history-e n stream) empty)]))
; Counts number of events on an event stream ; Counts number of events on an event stream
(define/contract count-b (event? . -> . any) (define/contract count-b (event? . -> . any)
(lambda (stream) (lambda (stream)
(accum-b (stream . -=> . add1) 0))) (hold (accum-e (stream . -=> . add1) 0) 0)))
; Keeps track of the largest value seen on a stream ; Keeps track of the largest value seen on a stream
(define/contract largest-val-b (event? . -> . any) (define/contract largest-val-b (event? . -> . any)
(lambda (stream) (lambda (stream)
(hold (accum-e (stream (hold (accum-e (stream
. ==> . . ==> .
(lambda (last) (lambda (last)
(lambda (x) (lambda (x)
(if (> x last) x last)))) (if (> x last) x last))))
-inf.0)))) -inf.0))))
; Keeps track of the smallest value seen on a stream ; Keeps track of the smallest value seen on a stream
(define/contract smallest-val-b (event? . -> . any) (define/contract smallest-val-b (event? . -> . any)