checks on ideque length Peter Lane (07 Jun 2017 00:19 UTC)
Re: checks on ideque length Peter Lane (07 Jun 2017 18:29 UTC)

Re: checks on ideque length Peter Lane 07 Jun 2017 18:29 UTC

I have raised a pull request to correct this issue, and also an internal
error I found with %ideque-drop.  A test case for each is included which
exposes the error in the original code, and passes with the change.

   thanks,

     Peter.

On 07/06/17 01:18, Peter Lane wrote:
> I was trying to use take/take-right to retrieve all the elements within
> a deque.  The specification suggests this should be possible:
>
>     (ideque-take ideque n)
>
>     (ideque-take-right ideque n)
>
>     Returns an ideque containing the first/last n elements of
>     ideque. It is an error if n is GREATER than the length of
>     ideque.
>
> However:
>
>  > (define d (ideque 1 2 3 4))
>  > (ideque-take d 4)
> Exception in %check-length: argument is out of range: with irritant 4
>
> The test case also builds an ideque of length 7 but only tries take for
> values 0 to 6.
>
> I think %check-length should be changed to permit n to be the
> ideque-length, by removing the -1 from:
>
>      (define (%check-length dq n)
>        (unless (<= 0 n (- (ideque-length dq) 1))
>
>
> Does that sound right?
>
>    thanks,
>
>      Peter.

--
Peter Lane
http://peterlane.info