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[det]dict_fill(+ValueIn, +Key, +Dict, -Value)
Implementation for the dicts_to_same_keys/3 OnEmpty closure that fills new cells with a copy of ValueIn. Note that copy_term/2 does not really copy ground terms. Below are two examples. Note that when filling empty cells with a variable, each empty cell is bound to a new variable.
?- dicts_to_same_keys([r{x:1}, r{y:2}], dict_fill(null), L).
L = [r{x:1, y:null}, r{x:null, y:2}].
?- dicts_to_same_keys([r{x:1}, r{y:2}], dict_fill(_), L).
L = [r{x:1, y:_G2005}, r{x:_G2036, y:2}].

Use dict_no_fill/3 to raise an error if a dict is missing a key.