A.4 library(assoc): Association lists
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
      • The SWI-Prolog library
        • library(assoc): Association lists
          • Introduction
          • Creating association lists
            • empty_assoc/1
            • list_to_assoc/2
            • ord_list_to_assoc/2
          • Querying association lists
          • Modifying association lists
          • Conversion predicates
          • Reasoning about association lists and their elements
    • Packages

A.4.2 Creating association lists

An association list is created with one of the following predicates:

[semidet]empty_assoc(?Assoc)
Is true if Assoc is the empty association list.
[det]list_to_assoc(+Pairs, -Assoc)
Create an association from a list Pairs of Key-Value pairs. List must not contain duplicate keys.
Errors
domain_error(unique_key_pairs, List) if List contains duplicate keys
[det]ord_list_to_assoc(+Pairs, -Assoc)
Assoc is created from an ordered list Pairs of Key-Value pairs. The pairs must occur in strictly ascending order of their keys.
Errors
domain_error(key_ordered_pairs, List) if pairs are not ordered.