Difference list

Difference list

In computer science, the term difference list may refer to one of two data structures for representing lists. One of these data structures contains two lists, and represents the difference of those two lists. The second data structure is a functional representation of a list with an efficient concatenation operation. In the second approach, difference lists are implemented as single-argument functions, which take a list as argument and prepend to that list. As a consequence, concatenation of difference lists of the second type is implemented essentially as function composition, which is O(1). However, of course the list still has to be constructed eventually (assuming all of its elements are needed), which is plainly at least O(n).

Difference lists as functions

A difference list of the second sort represents lists as a function f, which when given a list x, returns the list that f represents, prepended to x. It is typically used in functional programming languages such as Haskell, although it could be used in imperative languages as well. Whether this kind of difference list is more efficient than another list representations depends on usage patterns. If an algorithm builds a list by concatenating smaller lists, which are themselves built by concatenating still smaller lists, then use of difference lists can improve performance by effectively "flattening" the list building computations.

Examples of use are in the ShowS type in the Prelude of Haskell, and in Donald Bruce Stewart's difference list library for Haskell.


External links


Wikimedia Foundation. 2010.

Игры ⚽ Нужен реферат?

Look at other dictionaries:

  • Difference List — Der Begriff Difference List (Unterschiedsliste) kann sich auf zwei verschiedene Datenstrukturen in der Informatik beziehen. Zum einen bezeichnet es eine Datenstruktur, die zwei Listen enthält und den Unterschied zwischen diesen repräsentiert. Die …   Deutsch Wikipedia

  • Difference due to Memory — (Dm) indexes differences in neural activity during the study phase of an experiment for items that subsequently are remembered compared to items that are later forgotten. It is mainly discussed as an event related potential (ERP) effect that… …   Wikipedia

  • List of United Kingdom disasters by death toll — is a list of major disasters (excluding acts of war) which occurred in the United Kingdom (including territory that later became the Republic of Ireland) or involved UK citizens, in a definable incident or accident, e.g. a shipwreck, where the… …   Wikipedia

  • List of disasters of the United Kingdom and preceding states — is a list of major disasters (excluding acts of war but including acts of terrorism) which relate to the United Kingdom since 1707, the states that preceded it (including territory that later became the Republic of Ireland), or involved UK… …   Wikipedia

  • List of railway lines in Japan — lists existing railway lines in Japan alphabetically.The vast majority of Japanese railways are classified under two Japanese laws, one for nihongo|railways|鉄道|tetsudō and another for nihongo|trams|軌道|kidō. The difference between the two is a… …   Wikipedia

  • List of plantations in Maine — List of plantations in Maine, arranged in alphabetical order with (county) noted. A plantation in Maine is an organized form of municipal self government similar to but with less power than a town or a city. One difference is that plantations can …   Wikipedia

  • List of National Historic Landmarks in Alabama — …   Wikipedia

  • List of National Historic Landmarks in Oregon — …   Wikipedia

  • List of British Jewish writers — is a list that includes writers (novelists, poets, playwrights, journalists and others) from the United Kingdom and its predecessor states who are or were Jewish or of Jewish descent. Authors, A J * Grace Aguilar [http://www.jewishvoices.org/id62 …   Wikipedia

  • List of United States Presidential names — contains lists of nicknames, name origins, and the first, middle, and last names of each President of the United States. Most of the nicknames listed are political, such as Tricky Dick , which belonged to Richard Nixon, initialisms like T.R.… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”