A.15 library(dicts): Dict utilities
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
      • The SWI-Prolog library
        • library(dicts): Dict utilities
          • dicts_same_tag/2
          • dict_size/2
          • dict_keys/2
          • dicts_same_keys/2
          • dicts_to_same_keys/3
          • dict_fill/4
          • dicts_join/3
          • dicts_join/4
          • dicts_slice/3
          • dicts_to_compounds/4
    • Packages
Availability::- use_module(library(dicts)).(can be autoloaded)
Source[semidet]dicts_join(+Key, +Dicts1, +Dicts2, -Dicts)
Join two lists of dicts (Dicts1 and Dicts2) on Key. Each pair D1-D2 from Dicts1 and Dicts2 that have the same (==) value for Key creates a new dict D with the union of the keys from D1 and D2, provided D1 and D2 to not have conflicting values for some key. For example:
?- DL1 = [r{x:1,y:1},r{x:2,y:4}],
   DL2 = [r{x:1,z:2},r{x:3,z:4}],
   dicts_join(x, DL1, DL2, DL).
   DL = [r{x:1, y:1, z:2}, r{x:2, y:4}, r{x:3, z:4}].
Errors
existence_error(key, Key, Dict) if a dict in Dicts1 or Dicts2 does not contain Key.