It looks like sloppy code on my part. I assume it worked in some previous version, but I will change the exit call to take an argument. I assume something downstream wants a value now. I'll release a new version this evening.<br>
<br>Doug<br><br><div class="gmail_quote">On Mon, Jan 28, 2008 at 3:20 PM, Vincent Rayappa <<a href="mailto:vrayappa@gmail.com">vrayappa@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I would like to use the histogram module of the science collection to<br>
generate histograms with custom ranges.<br>
<br>
I tried:<br>
<br>
(define h1 (make-histogram 4))<br>
(set-histogram-ranges! h '#(0.0 1.0 2.0 4.0 16.0))<br>
<br>
So far so good, but when I try to add a value like this:<br>
<br>
(histogram-increment! h 5)<br>
<br>
I get this error:<br>
<br>
context expected 1 value, received 0 values<br>
.../histogram.ss:219:10: (call/ec (lambda (exit) (if (< x (....))<br>
(exit)) ((letrec-values ((....)) doloop) 0)))<br>
[unknown source]: (void?31 (val (histogram?29 histogram?27) (real?30 real?28)))<br>
<br>
Any idea what is going on?<br>
<br>
The function is defined like this:<br>
<br>
;; Increment the bin corresponding to the x value by one.<br>
<br>
(define (histogram-increment! h x)<br>
(let ((n (histogram-n h))<br>
(ranges (histogram-ranges h))<br>
(bins (histogram-bins h))<br>
(uniform-ranges? (histogram-ranges-uniform? h)))<br>
(if uniform-ranges?<br>
;; Compute bin<br>
(let ((i (inexact->exact<br>
(floor (/ (- x (vector-ref ranges 0))<br>
(/ (- (vector-ref ranges n)<br>
(vector-ref ranges 0))<br>
n))))))<br>
(if (<= 0 i (- n 1))<br>
(vector-set! bins i<br>
(+ (vector-ref bins i) 1))))<br>
;; Search for bin<br>
(let/ec exit ;; <---------- line #219<br>
(if (< x (vector-ref ranges 0))<br>
(exit))<br>
(do ((i 0 (+ i 1)))<br>
((= i n) (void))<br>
(if (< x (vector-ref ranges (+ i 1)))<br>
(begin<br>
(vector-set! bins i<br>
(+ (vector-ref bins i) 1))<br>
(exit))))))))<br>
<br>
<br>
Many Thanks,<br>
Vincent.<br>
_________________________________________________<br>
For list-related administrative tasks:<br>
<a href="http://list.cs.brown.edu/mailman/listinfo/plt-scheme" target="_blank">http://list.cs.brown.edu/mailman/listinfo/plt-scheme</a><br>
</blockquote></div><br>