aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/documentation/lux/data/collection/dictionary.lux
blob: 6cc473b7ffa3fe3445b7d816e37522f495aaf6d7 (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
(.require
 [library
  [lux (.except)
   ["$" documentation]
   [data
    [text (.only \n)
     ["%" \\format (.only format)]]]]]
 [\\library
  ["[0]" /]]
 ["[0]" /
  ["[1][0]" ordered]])

(.def .public documentation
  (.List $.Module)
  ($.module /._
            ""
            [($.default /.key_hash)
             ($.default /.key_already_exists)
             ($.default /.size)
             ($.default /.empty?)
             ($.default /.entries)
             ($.default /.keys)
             ($.default /.values)
             ($.default /.equivalence)
             ($.default /.functor)

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

             ($.definition /.empty
               "An empty dictionary."
               [(empty key_hash)])

             ($.definition /.has
               ""
               [(has key val dict)])

             ($.definition /.lacks
               ""
               [(lacks key dict)])

             ($.definition /.value
               ""
               [(value key dict)])

             ($.definition /.key?
               ""
               [(key? dict key)])

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

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

             ($.definition /.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)])

             ($.definition /.of_list
               ""
               [(of_list key_hash kvs)])

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

             ($.definition /.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)])

             ($.definition /.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)])

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