YAP 7.1.0
Association Maps

The following association list manipulation predicates are available once included with the use_module(library(assoc)) command. More...

Detailed Description

The following association list manipulation predicates are available once included with the use_module(library(assoc)) command.

The original library used Richard O'Keefe's implementation, on top of unbalanced binary trees The current code utilises code from the red-black trees library and emulates the SICStus Prolog interface

The library exports the following definitions:


Class Documentation

◆ empty_assoc/1

class empty_assoc/1

empty_assoc(+ Assoc)

Succeeds if association list Assoc is empty

◆ assoc_to_list/2

class assoc_to_list/2

assoc_to_list(+ Assoc,? List)

Given an association list Assoc unify List with a list of the form Key-Val, where the elements Key are in ascending order

◆ is_assoc/1

class is_assoc/1

is_assoc(+ Assoc)

Succeeds if Assoc is an association list, that is, if it is a red-black tree

◆ min_assoc/3

class min_assoc/3

min_assoc(+ Assoc,- Key,? Value)

Given the association list Assoc, Key in the smallest key in the list, and Value the associated value

◆ max_assoc/3

class max_assoc/3

max_assoc(+ Assoc,- Key,? Value)

Given the association list Assoc, Key in the largest key in the list, and Value the associated value

◆ gen_assoc/3

class gen_assoc/3

gen_assoc( ?Key, +Assoc, ?Valu_)

Given the association list Assoc, unify Key and Value with a key-value pair in the list It can be used to enumerate all elements in the association list

◆ get_assoc/3

class get_assoc/3

get_assoc(+ Key,+ Assoc,? Value)

If Key is one of the elements in the association list Assoc, return the associated value

◆ get_assoc/5

class get_assoc/5

get_assoc(+ Key,+ Assoc,? Value,+ NAssoc,? NValue)

If Key is one of the elements in the association list Assoc, return the associated value Value and a new association list NAssoc where Key is associated with NValue

◆ get_next_assoc/4

class get_next_assoc/4

get_next_assoc(+ Key,+ Assoc,? Next,? Value)

If Key is one of the elements in the association list Assoc, return the next key, Next, and its value, Value

◆ get_prev_assoc/4

class get_prev_assoc/4

get_prev_assoc(+ Key,+ Assoc,? Next,? Value)

If Key is one of the elements in the association list Assoc, return the previous key, Next, and its value, Value

◆ list_to_assoc/2

class list_to_assoc/2

list_to_assoc(+ List,? Assoc)

Given a list List such that each element of List is of the form Key-Val, and all the Keys are unique, Assoc is the corresponding association list

◆ ord_list_to_assoc/2

class ord_list_to_assoc/2

ord_list_to_assoc(+ List,? Assoc)

Given an ordered list List such that each element of List is of the form Key-Val, and all the Keys are unique, Assoc is the corresponding association list

◆ map_assoc/2

class map_assoc/2

map_assoc(+ Pred,+ Assoc)

Succeeds if the unary predicate name Pred( Val) holds for every element in the association list

◆ map_assoc/3

class map_assoc/3

map_assoc(+ Pred,+ Assoc,? New)

Given the binary predicate name Pred and the association list Assoc, New in an association list with keys in Assoc, and such that if Key-Val is in Assoc, and Key-Ans is in New, then Pred( Val, Ans) holds

◆ put_assoc/4

class put_assoc/4

put_assoc(+ Key,+ Assoc,+ Val,+ New)

The association list New includes and element of association key with Val, and all elements of Assoc that did not have key Key

◆ del_assoc/4

class del_assoc/4

del_assoc(+ Key, + Assoc, ? Val, ? NewAssoc)

Succeeds if NewAssoc is an association list, obtained by removing the element with Key and Val from the list Assoc

◆ del_min_assoc/4

class del_min_assoc/4

del_min_assoc(+ Assoc, ? Key, ? Val, ? NewAssoc)

Succeeds if NewAssoc is an association list, obtained by removing the smallest element of the list, with Key and Val from the list Assoc

◆ del_max_assoc/4

class del_max_assoc/4

del_max_assoc(+ Assoc, ? Key, ? Val, ? NewAssoc)

Succeeds if NewAssoc is an association list, obtained by removing the largest element of the list, with Key and Val from the list Assoc