aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/documentation/lux/data/collection/dictionary.lux
blob: 8368a6560356e1f926e16858acfe2cb6732715c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
(.using
 [library
  [lux (.except has revised)
   ["$" documentation (.only documentation:)]
   [control
    ["<>" parser
     ["<[0]>" code]]]
   [data
    ["[0]" text (.only \n)
     ["%" format (.only format)]]]
   [macro
    [syntax (.only syntax:)]
    ["[0]" code]
    ["[0]" template]]]]
 [\\library
  ["[0]" /]]
 ["[0]" / "_"
  ["[1][0]" ordered]
  ["[1][0]" plist]])

(documentation: (/.Dictionary key value)
  "A dictionary implemented as a Hash-Array Mapped Trie (HAMT).")

(documentation: /.empty
  "An empty dictionary."
  [(empty key_hash)])

(documentation: /.has
  ""
  [(has key val dict)])

(documentation: /.lacks
  ""
  [(lacks key dict)])

(documentation: /.value
  ""
  [(value key dict)])

(documentation: /.key?
  ""
  [(key? dict key)])

(documentation: /.has'
  "Only puts the KV-pair if the key is not already present."
  [(has' key val dict)])

(documentation: /.revised
  "Transforms the value located at key (if available), using the given function."
  [(revised key f dict)])

(documentation: /.revised'
  (format "Updates the value at the key; if it exists."
          \n "Otherwise, puts a value by applying the function to a default.")
  [(revised' key default f dict)])

(documentation: /.of_list
  ""
  [(of_list key_hash kvs)])

(documentation: /.composite
  (format "Merges 2 dictionaries."
          \n "If any collisions with keys occur, the values of dict2 will overwrite those of dict1.")
  [(composite dict2 dict1)])

(documentation: /.composite_with
  (format "Merges 2 dictionaries."
          \n "If any collisions with keys occur, a new value will be computed by applying 'f' to the values of dict2 and dict1.")
  [(composite_with f dict2 dict1)])

(documentation: /.re_bound
  "If there is a value under 'from_key', remove 'from_key' and store the value under 'to_key'."
  [(re_bound from_key to_key dict)])

(documentation: /.sub
  "A sub-dictionary, with only the specified keys."
  [(sub keys dict)])

(.def: .public documentation
  (.List $.Module)
  ($.module /._
            ""
            [..Dictionary
             ..empty
             ..has
             ..lacks
             ..value
             ..key?
             ..has'
             ..revised
             ..revised'
             ..of_list
             ..composite
             ..composite_with
             ..re_bound
             ..sub
             ($.default /.key_hash)
             ($.default /.key_already_exists)
             ($.default /.size)
             ($.default /.empty?)
             ($.default /.entries)
             ($.default /.keys)
             ($.default /.values)
             ($.default /.equivalence)
             ($.default /.functor)]
            [/ordered.documentation
             /plist.documentation]))