|Did you know ...||Search Documentation:|
|library(assoc): Association lists|
Authors: Richard A. O'Keefe, L.Damas, V.S.Costa and Markus Triska
An association list as implemented by this library is a collection of unique keys that are associated to values. Keys must be ground, values need not be.
An association list can be used to fetch elements via their keys and to enumerate its elements in ascending order of their keys.
This library uses AVL trees to implement association lists. This means that
are all O(
log(N)) worst-case (and
expected) time operations, where
N denotes the number of elements in the association list.
The logarithmic overhead is often acceptable in practice. Notable advantages of association lists over several other methods are:
library(assoc)is written entirely in Prolog, making it portable to other systems
An association list is created with one of the following predicates:
domain_error(unique_key_pairs, List)if List contains duplicate keys
domain_error(key_ordered_pairs, List)if pairs are not ordered.
An association list can be queried with:
type_error(assoc, Assoc)if Assoc is not an association list.
Elements of an association list can be changed and inserted with:
Conversion of (parts of) an association list to lists is possible with:
Further inspection predicates of an association list and its elements are: