Re: Last call for comments on SRFI 179: Nonempty Intervals and Generalized Arrays (Updated) Bradley Lucier 03 May 2020 03:27 UTC
On 5/2/20 10:56 PM, Bradley Lucier wrote: > APL seems to pun 1 x 1 arrays with scalar values (both ways), and SRFI > 179 does not do that, so it's not terribly easy to reproduce the other > example on that page. But one can calculate the other example as > > (define X > (list->specialized-array '(1 3 5 7) (make-interval '#(4)))) > > (define Y > (list->specialized-array '(2 3 6 7) (make-interval '#(4)))) > > (array-reduce + (array-map (lambda (x y) (if (= x y) 1 0)) X Y)) > > and you get 2, as expected. (The last expression is pulled out from the > definition of inner-product.) One can (define X (list->specialized-array '(1 3 5 7) (make-interval '#(1 4)))) (define Y (list->specialized-array '(2 3 6 7) (make-interval '#(4 1)))) (array-display (inner-product X + (lambda (x y) (if (= x y) 1 0)) Y)) which displays 2, the single element of the 1 x 1 array. Brad