NAME
Muldis::D::Ext::Bag - Muldis D extension for Bag specific operators
VERSION
This document is Muldis::D::Ext::Bag version 0.25.0.
PREFACE
This document is part of the Muldis D language specification, whose root document is Muldis::D; you should read that root document before you read this one, which provides subservient details.
DESCRIPTION
Muldis D has a mandatory core set of system-defined (eternally available) entities, which is referred to as the Muldis D core or the core; they are the minimal entities that all Muldis D implementations need to provide; they are mutually self-describing and are used to bootstrap the language; any entities outside the core, called Muldis D extensions, are non-mandatory and are defined in terms of the core or each other, but the reverse isn't true.
This current Bag document describes the system-defined Muldis D Bag Extension, which consists of generic operators that are specific to the Bag parameterized relation type, and said operators are short-hands for generic relational operators in the language core.
This current document does not describe the polymorphic operators that all types, or some types including core types, have defined over them; said operators are defined once for all types in Muldis::D::Core.
This documentation is pending.
SYSTEM-DEFINED BAG-CONCERNING FUNCTIONS
Each assuming parameter is optional and defaults to the zero-attribute tuple if no explicit argument is given to it.
function sys.std.Bag.cardinality result UInt params { topic(Bag) }-
This function is like
sys.std.Core.Relation.cardinalitybut that it accounts for the greater-than-one multiplicity of values in its argument; it results in the sum of thecountattribute of its argument. function sys.std.Bag.is_member result Bool params { bag(Bag), value(ScaTupRel) }-
This function is the same as
sys.std.Set.is_member, including that matching ofvalueis done against thevalueattribute, except that it works with aBagrather than aSet. function sys.std.Bag.is_not_member result Bool params { bag(Bag), value(ScaTupRel) }-
This function is exactly the same as
sys.std.Bag.is_memberexcept that it results in the opposite boolean value when given the same arguments. function sys.std.Bag.count result UInt params { bag(Bag), value(ScaTupRel) }-
This function results in the multiplicity / count of occurrances of
valueinbag; if a tuple exists inbagwhosevalueattribute isvalue, then the result is itscountattribute; otherwise the result is zero. function sys.std.Bag.insertion result Bag params { bag(Bag), value(ScaTupRel) }-
This function is the same as
sys.std.Set.insertionas peris_memberbut that its result differs depending on whethervaluealready exists inbag; if it does, then no new tuple is added, but thecountattribute for the matching tuple is incremented by 1; if it does not, then a new tuple is added where itsvalueisvalueand itscountis 1. function sys.std.Bag.deletion result Bag params { bag(Bag), value(ScaTupRel) }-
This function is the same as
sys.std.Set.deletionas peris_memberbut that its result differs depending on what thecountfor any tuple matchingvaluethat already exists inbagis; if thecountis greater than 1, then it is decremented by 1; if it is equal to 1, then the tuple whosevalueisvalueis deleted. function sys.std.Bag.reduction result ScaTupRel params { topic(Bag), func(Cat.FuncRef), assuming(QuasiTuple)?, identity(ScaTupRel) }-
This function is the same as
sys.std.Set.reduction, including that input values for the reduction come from thevalueattribute oftopic, except that it works with aBagrather than aSet;funcis invoked extra times, where both itsv1andv2arguments might be different instances of the same value having >= 2 multiplicity. function sys.std.Bag.maybe_reduction result Maybe params { topic(Bag), func(Cat.FuncRef), assuming(QuasiTuple)? }-
This function is to
sys.std.Set.maybe_reductionassys.std.Bag.reductionis tosys.std.Set.reduction. function sys.std.Bag.Set_from_Bag result Set params { topic(Bag) }-
This function results in the
Setthat is the projection of thevalueattribute of itsBagargument. function sys.std.Bag.Bag_from_Set result Bag params { topic(Set) }-
This function results in the
Bagthat is the extension of itsSetargument with a newcountattribute whose value for every tuple is 1. function sys.std.Bag.Bag_from_wrap result bag_of.Tuple params { topic(Relation) }-
This function results in a
Bagwhosevalueattribute is tuple-typed and that attribute's values are all the tuples oftopic; is a short-hand for a relational wrap of all attributes oftopicsuch that the new tuple-valued attribute is namedvalue, and then that result is extended with acountattribute whose value for every tuple is 1. function sys.std.Bag.Bag_from_attr result Bag params { topic(Relation), name(Cat.Name) }-
This function results in a
Bagconsisting of all the values of the attribute oftopicnamed byname. It is a short-hand for first doing a relational group on all attributes oftopicbesidesnameto 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 tovalueandcountrespectively. function sys.std.Bag.is_subset result Bool params { look_in(Bag), look_for(Bag) }-
This function is like
sys.std.Core.Relation.is_subsetbut that it accounts for the greater-than-one multiplicity of values in its arguments; this function returnsBool:trueiff the multiplicity of eachlook_forvalue is less than or equal to the multiplicity of its counterpartlook_invalue. function sys.std.Bag.is_not_subset result Bool params { look_in(Bag), look_for(Bag) }-
This function is like
sys.std.Core.Relation.is_not_subsetas peris_subset. function sys.std.Bag.is_proper_subset result Bool params { look_in(Bag), look_for(Bag) }-
This function is like
sys.std.Core.Relation.is_proper_subsetas peris_subset. TODO: What is its definition? function sys.std.Bag.is_not_proper_subset result Bool params { look_in(Bag), look_for(Bag) }-
This function is like
sys.std.Core.Relation.is_not_proper_subsetas peris_subset. TODO: What is its definition? function sys.std.Bag.union result Bag params { topic(set_of.Bag) }-
This function is like
sys.std.Core.Relation.unionbut that it just looks at thevalueattribute of its argument elements when determining what element tuples correspond; then for each tuple in the result, itscountattribute value is the maximum of thecountattribute values of its corresponding input element tuples. function sys.std.Bag.intersection result Bag params { topic(set_of.Bag) }-
This function is like
sys.std.Core.Relation.intersectionasunionis likesys.std.Core.Relation.union; the minimum ofcountattribute values is used rather than the maximum. function sys.std.Bag.difference result Bag params { source(Bag), filter(Bag) }-
This function is like
sys.std.Core.Relation.differenceasunionis likesys.std.Core.Relation.union; for corresponding input tuples, the result only has a tuple with the samevalueif thecountof thesourcetuple is greater than thecountof thefiltertuple, and thecountof the result tuple is the difference of those two.
SEE ALSO
Go to Muldis::D for the majority of distribution-internal references, and Muldis::D::SeeAlso for the majority of distribution-external references.
AUTHOR
Darren Duncan (perl@DarrenDuncan.net)
LICENSE AND COPYRIGHT
This file is part of the formal specification of the Muldis D language.
Muldis D is Copyright © 2002-2008, Darren Duncan.
See the LICENSE AND COPYRIGHT of Muldis::D for details.
TRADEMARK POLICY
The TRADEMARK POLICY in Muldis::D applies to this file too.
ACKNOWLEDGEMENTS
The ACKNOWLEDGEMENTS in Muldis::D apply to this file too.