A.4 library(assoc): Association lists
All Application Manual Name SummaryHelp

  • Documentation
    • Reference manual
      • The SWI-Prolog library
        • library(assoc): Association lists
          • Introduction
          • Creating association lists
          • Querying association lists
          • Modifying association lists
            • put_assoc/4
            • del_assoc/4
            • del_min_assoc/4
            • del_max_assoc/4
          • Conversion predicates
          • Reasoning about association lists and their elements
    • Packages

A.4.4 Modifying association lists

Elements of an association list can be changed and inserted with:

[det]put_assoc(+Key, +Assoc0, +Value, -Assoc)
Assoc is Assoc0, except that Key is associated with Value. This can be used to insert and change associations.
[semidet]del_assoc(+Key, +Assoc0, ?Value, -Assoc)
True if Key-Value is in Assoc0. Assoc is Assoc0 with Key-Value removed.
[semidet]del_min_assoc(+Assoc0, ?Key, ?Val, -Assoc)
True if Key-Value is in Assoc0 and Key is the smallest key. Assoc is Assoc0 with Key-Value removed. Warning: This will succeed with no bindings for Key or Val if Assoc0 is empty.
[semidet]del_max_assoc(+Assoc0, ?Key, ?Val, -Assoc)
True if Key-Value is in Assoc0 and Key is the greatest key. Assoc is Assoc0 with Key-Value removed. Warning: This will succeed with no bindings for Key or Val if Assoc0 is empty.