Next: , Previous: , Up: Top   [Contents][Index]


3 Difference Lists

Repeatedly appending to a list is a common, if inefficient pattern in functional programs. Usually the trick we use is to build up the list in reverse, and then to reverse it as the last action of a function. Dlists are a representation of lists as functions that provide for constant time append to either the front or end of a dlist that may be used instead.

Function: dlist OBJ

Return a <dlist> containing all the given arguments.

(dlist 1 2 3)   ⇒ #[dlist 1 2 3]
Function: dlist? OBJ

Return #t if OBJ is a <dlist>, #f otherwise.

Function: dlist-cons item dell

Return a new <dlist> created by prepending item to the head of dell.

(let* ((dell (dlist 5))
       (dell (dlist-cons 4 dell))
       (dell (dlist-snoc dell 6)))
  dell)
⇒ #[dlist 4 5 6]
Function: dlist-snoc dell item

Return a new <dlist> created by appending item to the tail of dell.

Function: dlist-append dell

Return a new <dlist> consisting of the concatenation of the elements of the dell arguments. If no arguments are given: return the empty <dlist>.

(dlist-append (dlist 1 2)
              (dlist 3 4)
              (dlist 5 6)
              (dlist 7 8))
⇒ #[dlist 1 2 3 4 5 6 7 8]
Function: dlist->list dell

Return a list consisting of all the elements of the dell.

Function: list->dlist list-of-items

Return a <dlist> consisting of all the elements of the given list argument.

Function: dlist=? dell

Return #t if all the dell arguments are equal; otherwise return #f. If no arguments are given: return #t.


Next: , Previous: , Up: Top   [Contents][Index]

This document describes version 0.5.0-devel.1 of MMCK PFDS.