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)

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

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/scheme.html