I think I've run into this problem before. The type of array-slice-ref is
(Array A) (Listof Slice-Spec) -> (Array A)
where Slice-Spec = (U (Sequenceof Integer) Integer ....)
The problem is that integers are also sequences, so the contract
generated for Slice-Spec just discards the Integer part. (I can't
remember if it's done by type->contract or by or/c.) Then when given an
integer, the sequenceof contract accepts it and produces a sequence
proxy that is not an integer.
Basically, 0 gets turned into (in-range 0), which is an empty sequence.
I don't know of a workaround that uses only untyped code, but you can
define a typed alternative version of array-slice-ref that accepts a
version of Slice-Spec with the (Sequenceof Integer) removed (or replaced
with lists and/or vectors). Then if you use that in untyped code, it
should work as expected because the overlap is gone.
Ryan
On 10/21/2015 12:30 PM, Berthold Bäuml wrote:
When using array-slice-ref from math/array I get different results
when executing it #lang typed/racket or #lang racket (see below). The
typed/racket result is consistent with the documentation, the untyped
one seems to be wrong.
Berthold
#lang typed/racket
(require math/array)
(define arr
(array
#[#[#["000" "001" "002" "003"]
#["010" "011" "012" "013"]
#["020" "021" "022" "023"]]
#[#["100" "101" "102" "103"]
#["110" "111" "112" "113"]
#["120" "121" "122" "123"]]]))
(array-slice-ref arr (list 0 ::…))
computes to:
(array #[#["000" "001" "002" "003"] #["010" "011" "012" "013"] #["020" "021" "022"
"023"]])
wheras:
#lang racket
(require math/array)
(define arr
(array
#[#[#["000" "001" "002" "003"]
#["010" "011" "012" "013"]
#["020" "021" "022" "023"]]
#[#["100" "101" "102" "103"]
#["110" "111" "112" "113"]
#["120" "121" "122" "123"]]]))
(array-slice-ref arr (list 0 ::…))
computes to:
(array #[])
--
You received this message because you are subscribed to the Google Groups "Racket
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.