deque?
non-empty-deque/ c
deque-empty
deque-empty?
deque-unshift
deque-push
deque-shift
deque-pop
deque-last
deque-first
deque-elements
deque-map
deque-length
Version: 4.2.1.5

Functional Batched Deque

Jay McCarthy <jay at plt-scheme dot org>

A functional deque based on Okasaki’s work and Jens Axel Søgaard’s code.

 (require (planet jaymccarthy/batched-deque))

(deque? v)  boolean?
  v : any/c

Tests deque-ness.

non-empty-deque/c : contract?

A contract for non-empy deques.

deque-empty : deque?

An empty deque.

(deque-empty? dq)  boolean?
  dq : deque?

Returns true if dq is empty.

(deque-unshift v dq)  non-empty-deque/c
  v : any/c
  dq : deque?

Returns a deque that is the same as dq except that it starts with v.

(deque-push v dq)  non-empty-deque/c
  v : any/c
  dq : deque?

Returns a deque that is the same as dq except that it end with v.

(deque-shift dq)  deque?
  dq : non-empty-deque/c

Returns a deque that is the same as dq except it is missing the first element.

(deque-pop dq)  deque?
  dq : non-empty-deque/c

Returns a deque that is the same as dq except it is missing the last element.

(deque-last dq)  any/c
  dq : non-empty-deque/c

Returns the last element of dq.

(deque-first dq)  any/c
  dq : non-empty-deque/c

Returns the first element of dq.

(deque-elements dq)  (listof any/c)
  dq : deque?

Returns elements of dq as a list.

(deque-map f dq)  deque?
  f : (-> any/c any/c)
  dq : deque?

Maps f over dq, returning a new deque.

(deque-length dq)  exact-nonnegative-integer?
  dq : deque?

Returns the number of elements in dq.