chibi-scheme
chibi-scheme copied to clipboard
SRFI 231: interval-projection problem?
I'm testing chibi's SRFI 231 implementation, but I'm not really confident I'm doing it correctly. I'm trying
(test-values (values (make-interval '#())
(make-interval '#(1 1)))
(interval-projections (make-interval '#(0 0) '#(1 1)) 2))
(I'm not sure this is correct, I'm following the "put the expected result first" principle.) I'm getting
FAIL: ...(interval-projections (make-interval '#(0 0) '#(1 1)) 2)
expected ({Interval #43 #() #()} {Interval #43 #(0 0) #(1 1)}) but got ({Interval #43 #(0 0) #(1 1)} {Interval #43 #() #()})
on line 145 of file "/usr/local/chibi//share/chibi/chibi/test.scm"
(call-with-values (lambda () (interval-projections (make-interval '#(0 0) '#(1 1)) 2)) (lambda results results))
It appears that this definition in base.scm:
(define (interval-projections iv rd)
(values (make-interval (vector-copy (interval-lb iv) 0 rd)
(vector-copy (interval-ub iv) 0 rd))
(make-interval (vector-copy (interval-lb iv) rd)
(vector-copy (interval-ub iv) rd))))
is incorrect, it puts rd dimensions into the first interval instead of the second.
If you agree, I'll draw up a PR.
Sorry, I lost track of these issues for a while and just got back to the SRFI 231 implementation. I believe this is working now, can you double check?
This works.