aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/documentation/lux/data/collection/dictionary.lux
blob: 1d2b483431aee08a996392ebd642fd9ef175b1dc (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
... This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
... If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.

(.require
 [library
  [lux (.except)
   ["$" documentation]
   [data
    [text (.only \n)
     ["%" \\format (.only format)]]
    [collection
     ["[0]" list]]]]]
 [\\library
  ["[0]" /]]
 ["[0]" /
  ["[1][0]" ordered]])

(def .public documentation
  (List $.Documentation)
  (list.partial ($.module /._
                          "")

                ($.definition /.key_hash)
                ($.definition /.key_already_exists)
                ($.definition /.size)
                ($.definition /.empty?)
                ($.definition /.entries)
                ($.definition /.keys)
                ($.definition /.values)
                ($.definition /.equivalence)
                ($.definition /.functor)

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

                ($.definition /.empty
                  "An empty dictionary."
                  ($.example (empty key_hash)))

                ($.definition /.has
                  ""
                  ($.example (has key val dict)))

                ($.definition /.lacks
                  ""
                  ($.example (lacks key dict)))

                ($.definition /.value
                  ""
                  ($.example (value key dict)))

                ($.definition /.key?
                  ""
                  ($.example (key? dict key)))

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

                ($.definition /.revised
                  "Transforms the value located at key (if available), using the given function."
                  ($.example (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.")
                  ($.example (revised' key default f dict)))

                ($.definition /.of_list
                  ""
                  ($.example (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.")
                  ($.example (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.")
                  ($.example (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'."
                  ($.example (re_bound from_key to_key dict)))

                ($.definition /.sub
                  "A sub-dictionary, with only the specified keys."
                  ($.example (sub keys dict)))

                /ordered.documentation
                ))