diff options
Diffstat (limited to 'stdlib/source/library/lux/data/collection/set/multi.lux')
-rw-r--r-- | stdlib/source/library/lux/data/collection/set/multi.lux | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/stdlib/source/library/lux/data/collection/set/multi.lux b/stdlib/source/library/lux/data/collection/set/multi.lux index ea7fd7df0..6de0ed5df 100644 --- a/stdlib/source/library/lux/data/collection/set/multi.lux +++ b/stdlib/source/library/lux/data/collection/set/multi.lux @@ -14,7 +14,7 @@ [number ["n" nat]]] [type - [abstract {"+" abstract: :abstraction :representation ^:representation}]]]] + ["[0]" abstract {"+" abstract: abstraction representation}]]]] ["[0]" // [// ["[0]" list ("[1]#[0]" mix monoid)] @@ -25,42 +25,42 @@ (def: .public empty (All (_ a) (-> (Hash a) (Set a))) - (|>> dictionary.empty :abstraction)) + (|>> dictionary.empty abstraction)) (def: .public size (All (_ a) (-> (Set a) Nat)) - (|>> :representation dictionary.values (list#mix n.+ 0))) + (|>> representation dictionary.values (list#mix n.+ 0))) (def: .public (has multiplicity elem set) (All (_ a) (-> Nat a (Set a) (Set a))) (case multiplicity 0 set _ (|> set - :representation + representation (dictionary.revised' elem 0 (n.+ multiplicity)) - :abstraction))) + abstraction))) (def: .public (lacks multiplicity elem set) (All (_ a) (-> Nat a (Set a) (Set a))) (case multiplicity 0 set - _ (case (dictionary.value elem (:representation set)) + _ (case (dictionary.value elem (representation set)) {.#Some current} - (:abstraction + (abstraction (if (n.> multiplicity current) - (dictionary.revised elem (n.- multiplicity) (:representation set)) - (dictionary.lacks elem (:representation set)))) + (dictionary.revised elem (n.- multiplicity) (representation set)) + (dictionary.lacks elem (representation set)))) {.#None} set))) (def: .public (multiplicity set elem) (All (_ a) (-> (Set a) a Nat)) - (|> set :representation (dictionary.value elem) (maybe.else 0))) + (|> set representation (dictionary.value elem) (maybe.else 0))) (def: .public list (All (_ a) (-> (Set a) (List a))) - (|>> :representation + (|>> representation dictionary.entries (list#mix (function (_ [elem multiplicity] output) (list#composite (list.repeated multiplicity elem) output)) @@ -69,13 +69,13 @@ (template [<name> <composite>] [(def: .public (<name> parameter subject) (All (_ a) (-> (Set a) (Set a) (Set a))) - (:abstraction (dictionary.merged_with <composite> (:representation parameter) (:representation subject))))] + (abstraction (dictionary.merged_with <composite> (representation parameter) (representation subject))))] [union n.max] [sum n.+] ) - (def: .public (intersection parameter (^:representation subject)) + (def: .public (intersection parameter (abstract.pattern subject)) (All (_ a) (-> (Set a) (Set a) (Set a))) (list#mix (function (_ [elem multiplicity] output) (..has (n.min (..multiplicity parameter elem) @@ -88,7 +88,7 @@ (def: .public (difference parameter subject) (All (_ a) (-> (Set a) (Set a) (Set a))) (|> parameter - :representation + representation dictionary.entries (list#mix (function (_ [elem multiplicity] output) (..lacks multiplicity elem output)) @@ -97,7 +97,7 @@ (def: .public (sub? reference subject) (All (_ a) (-> (Set a) (Set a) Bit)) (|> subject - :representation + representation dictionary.entries (list.every? (function (_ [elem multiplicity]) (|> elem @@ -106,7 +106,7 @@ (def: .public (support set) (All (_ a) (-> (Set a) (//.Set a))) - (let [(^.let set [hash _]) (:representation set)] + (let [(^.let set [hash _]) (representation set)] (|> set dictionary.keys (//.of_list hash)))) @@ -114,9 +114,9 @@ (implementation: .public equivalence (All (_ a) (Equivalence (Set a))) - (def: (= (^:representation reference) sample) + (def: (= (abstract.pattern reference) sample) (and (n.= (dictionary.size reference) - (dictionary.size (:representation sample))) + (dictionary.size (representation sample))) (|> reference dictionary.entries (list.every? (function (_ [elem multiplicity]) @@ -129,7 +129,7 @@ (def: &equivalence ..equivalence) - (def: (hash (^:representation set)) + (def: (hash (abstract.pattern set)) (let [[hash _] set] (list#mix (function (_ [elem multiplicity] acc) (|> elem (# hash hash) (n.* multiplicity) (n.+ acc))) |