=pod =encoding utf8 =head1 NAME Muldis::D::Core::Bag - Muldis D Bag specific operators =head1 VERSION This document is Muldis::D::Core::Bag version 0.148.0. =head1 PREFACE This document is part of the Muldis D language specification, whose root document is L; you should read that root document before you read this one, which provides subservient details. Moreover, you should read the L document before this current document, as that forms its own tree beneath a root document branch. =head1 DESCRIPTION This document describes generic operators that are specific to the C parameterized relation type, and said operators are short-hands for more generic relational operators. I =head1 FUNCTIONS IMPLEMENTING VIRTUAL COLLECTIVE FUNCTIONS =head2 sys.std.Core.Bag.has_member C<< function has_member (Bool <-- coll : Bag, value : Universal) implements sys.std.Core.Collective.has_member {...} >> This function is the same as C, including that matching of C is done against the C attribute, except that it works with a C rather than a C. =head2 sys.std.Core.Bag.has_not_member C<< function has_not_member (Bool <-- coll : Bag, value : Universal) implements sys.std.Core.Collective.has_not_member {...} >> This function is exactly the same as C except that it results in the opposite boolean value when given the same arguments. =head2 sys.std.Core.Bag.value_is_member C<< function value_is_member (Bool <-- value : Universal, coll : Bag) implements sys.std.Core.Collective.value_is_member {...} >> This function is an alias for C. This function is the same as C, including that matching of C is done against the C attribute, except that it works with a C rather than a C. =head2 sys.std.Core.Bag.value_is_not_member C<< function value_is_not_member (Bool <-- value : Universal, coll : Bag) implements sys.std.Core.Collective.value_is_not_member {...} >> This function is an alias for C. This function is exactly the same as C except that it results in the opposite boolean value when given the same arguments. =head1 GENERIC RELATIONAL FUNCTIONS FOR BAGS =head2 sys.std.Core.Bag.cardinality C<< function cardinality (NNInt <-- topic : Bag) {...} >> This function is like C but that it accounts for the greater-than-one multiplicity of values in its argument; it results in the sum of the C attribute of its argument. Note that this operation is also known as C<#+>. =head2 sys.std.Core.Bag.count C<< function count (NNInt <-- bag : Bag, value : Universal) {...} >> This function results in the multiplicity / count of occurrances of C in C; if a tuple exists in C whose C attribute is C, then the result is its C attribute; otherwise the result is zero. =head2 sys.std.Core.Bag.insertion C<< function insertion (Bag <-- bag : Bag, value : Universal) {...} >> This function is the same as C as per C but that its result differs depending on whether C already exists in C; if it does, then no new tuple is added, but the C attribute for the matching tuple is incremented by 1; if it does not, then a new tuple is added where its C is C and its C is 1. Actually this function differs in another way, such that it is semantically the single-tuple case of C, and is not the single-tuple case of C (which is the direct analogy to set union). =head2 sys.std.Core.Bag.deletion C<< function deletion (Bag <-- bag : Bag, value : Universal) {...} >> This function is the same as C as per C but that its result differs depending on what the C for any tuple matching C that already exists in C is; if the C is greater than 1, then it is decremented by 1; if it is equal to 1, then the tuple whose C attribute is C is deleted. =head2 sys.std.Core.Bag.reduction C<< function reduction (Universal <-- topic : Bag, func : ValRedCFuncNC, identity : Universal) {...} >> This function is the same as C, including that input values for the reduction come from the C attribute of C, except that it works with a C rather than a C; C is invoked extra times, where both its C and C arguments might be different instances of the same value having >= 2 multiplicity. =head2 sys.std.Core.Bag.Bag_from_wrap C<< function Bag_from_wrap (bag_of.Tuple <-- topic : Relation) {...} >> This function results in a C whose C attribute is tuple-typed and that attribute's values are all the tuples of C; it is a short-hand for a relational wrap of all attributes of C such that the new tuple-valued attribute is named C, and then that result is extended with a C attribute whose value for every tuple is 1. =head2 sys.std.Core.Bag.Bag_from_cmpl_group C<< function Bag_from_cmpl_group (bag_of.Tuple <-- topic : Relation, group_per : set_of.Name) {...} >> This function is like C but that the C is C and all the other attributes that would have been in the result are wrapped in a single tuple-valued attribute named C. This function is to C what C is to C. =head2 sys.std.Core.Bag.Bag_from_attr C<< function Bag_from_attr (Bag <-- topic : Relation, name : Name) {...} >> This function results in a C consisting of all the values of the attribute of C named by C. It is a short-hand for first doing a relational group on all attributes of C besides C to produce a new relation-typed attribute, and then extending the result of the group with a new positive integer attribute whose values are the cardinality of the relation-valued attribute's values, and then doing a binary projection of the named attribute and the new integer attribute plus their renaming to C and C respectively. =head2 sys.std.Core.Bag.is_subset C<< function is_subset (Bool <-- topic : Bag, other : Bag) {...} >> This function is like C but that it accounts for the greater-than-one multiplicity of values in its arguments; this function returns C iff the multiplicity of each C value is less than or equal to the multiplicity of its counterpart C value. Note that this operation is also known as C<⊆+> or C<< {<=}+ >>. =head2 sys.std.Core.Bag.is_not_subset C<< function is_not_subset (Bool <-- topic : Bag, other : Bag) {...} >> This function is like C as per C. Note that this operation is also known as C<⊈+> or C<< {!<=}+ >>. =head2 sys.std.Core.Bag.is_superset C<< function is_superset (Bool <-- topic : Bag, other : Bag) {...} >> This function is an alias for C except that it transposes the C and C arguments. This function is like C but that it accounts for the greater-than-one multiplicity of values in its arguments; this function returns C iff the multiplicity of each C value is greater than or equal to the multiplicity of its counterpart C value. Note that this operation is also known as C<⊇+> or C<< {>=}+ >>. =head2 sys.std.Core.Bag.is_not_superset C<< function is_not_superset (Bool <-- topic : Bag, other : Bag) {...} >> This function is an alias for C except that it transposes the C and C arguments. This function is like C as per C. Note that this operation is also known as C<⊉+> or C<< {!>=}+ >>. =head2 sys.std.Core.Bag.is_proper_subset C<< function is_proper_subset (Bool <-- topic : Bag, other : Bag) {...} >> This function is like C as per C. I Note that this operation is also known as C<⊂+> or C<< {<}+ >>. =head2 sys.std.Core.Bag.is_not_proper_subset C<< function is_not_proper_subset (Bool <-- topic : Bag, other : Bag) {...} >> This function is like C as per C. I Note that this operation is also known as C<⊄+> or C<< {!<}+ >>. =head2 sys.std.Core.Bag.is_proper_superset C<< function is_proper_superset (Bool <-- topic : Bag, other : Bag) {...} >> This function is an alias for C except that it transposes the C and C arguments. This function is like C as per C. Note that this operation is also known as C<⊃+> or C<< {>}+ >>. =head2 sys.std.Core.Bag.is_not_proper_superset C<< function is_not_proper_superset (Bool <-- topic : Bag, other : Bag) {...} >> This function is an alias for C except that it transposes the C and C arguments. This function is like C as per C. Note that this operation is also known as C<⊅+> or C<< {!>}+ >>. =head2 sys.std.Core.Bag.union C<< function union (Bag <-- topic : set_of.Bag) {...} >> This function is like C but that it just looks at the C attribute of its argument elements when determining what element tuples correspond; then for each tuple in the result, its C attribute value is the maximum of the C attribute values of its corresponding input element tuples. Note that this operation is also known as C<∪+> or C. =head2 sys.std.Core.Bag.union_sum C<< function union_sum (Bag <-- topic : bag_of.Bag) {...} >> This function is like C but that for each pair of argument elements being unioned, the output C value is the sum of the input C values rather than being the maximum of the inputs. Note that this operation is also known as C<∪++> or C. =head2 sys.std.Core.Bag.intersection C<< function intersection (Bag <-- topic : set_of.Bag) {...} >> This function is like C as C is like C; the minimum of C attribute values is used rather than the maximum. Note that this operation is also known as C<∩+> or C. =head2 sys.std.Core.Bag.diff C<< function diff (Bag <-- source : Bag, filter : Bag) {...} >> This function is like C as C is like C; for corresponding input tuples, the result only has a tuple with the same C if the C of the C tuple is greater than the C of the C tuple, and the C of the result tuple is the difference of those two. Note that this operation is also known as C or C or C<∖+>. =head1 SEE ALSO Go to L for the majority of distribution-internal references, and L for the majority of distribution-external references. =head1 AUTHOR Darren Duncan (C) =head1 LICENSE AND COPYRIGHT This file is part of the formal specification of the Muldis D language. Muldis D is Copyright © 2002-2011, Muldis Data Systems, Inc. See the LICENSE AND COPYRIGHT of L for details. =head1 TRADEMARK POLICY The TRADEMARK POLICY in L applies to this file too. =head1 ACKNOWLEDGEMENTS The ACKNOWLEDGEMENTS in L apply to this file too. =cut