NAME
Muldis::D::Ext::Bag - Muldis D extension for Bag specific operators
VERSION
This document is Muldis::D::Ext::Bag version 0.98.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
sys.std.Bag.cardinality
function sys.std.Bag.cardinality (NNInt <-- $topic : Bag)
This function is like sys.std.Core.Relation.cardinality
but that it accounts for the greater-than-one multiplicity of values in its argument; it results in the sum of the count
attribute of its argument. Note that this operation is also known as M#
.
sys.std.Bag.has_member
function sys.std.Bag.has_member (Bool <-- $bag : Bag, $value : Universal)
This function is the same as sys.std.Set.has_member
, including that matching of value
is done against the value
attribute, except that it works with a Bag
rather than a Set
. Note that this operation is also known as B∋
.
sys.std.Bag.has_not_member
function sys.std.Bag.has_not_member (Bool <-- $bag : Bag, $value : Universal)
This function is exactly the same as sys.std.Bag.has_member
except that it results in the opposite boolean value when given the same arguments. Note that this operation is also known as B∌
.
sys.std.Bag.value_is_member
function sys.std.Bag.value_is_member (Bool <-- $value : Universal, $bag : Bag)
This function is an alias for sys.std.Bag.has_member
. This function is the same as sys.std.Set.value_is_member
, including that matching of value
is done against the value
attribute, except that it works with a Bag
rather than a Set
. Note that this operation is also known as B∈
.
sys.std.Bag.value_is_not_member
function sys.std.Bag.value_is_not_member (Bool <-- $value : Universal, $bag : Bag)
This function is an alias for sys.std.Bag.has_not_member
. This function is exactly the same as sys.std.Bag.value_is_member
except that it results in the opposite boolean value when given the same arguments. Note that this operation is also known as B¬in;
.
sys.std.Bag.count
function sys.std.Bag.count (NNInt <-- $bag : Bag, $value : Universal)
This function results in the multiplicity / count of occurrances of value
in bag
; if a tuple exists in bag
whose value
attribute is value
, then the result is its count
attribute; otherwise the result is zero.
sys.std.Bag.insertion
function sys.std.Bag.insertion (Bag <-- $bag : Bag, $value : Universal)
This function is the same as sys.std.Set.insertion
as per has_member
but that its result differs depending on whether value
already exists in bag
; if it does, then no new tuple is added, but the count
attribute for the matching tuple is incremented by 1; if it does not, then a new tuple is added where its value
is value
and its count
is 1. Actually this function differs in another way, such that it is semantically the single-tuple case of sys.std.Bag.union_sum
, and is not the single-tuple case of sys.std.Bag.union
(which is the direct analogy to set union).
sys.std.Bag.deletion
function sys.std.Bag.deletion (Bag <-- $bag : Bag, $value : Universal)
This function is the same as sys.std.Set.deletion
as per has_member
but that its result differs depending on what the count
for any tuple matching value
that already exists in bag
is; if the count
is greater than 1, then it is decremented by 1; if it is equal to 1, then the tuple whose value
attribute is value
is deleted.
sys.std.Bag.reduction
function sys.std.Bag.reduction (Universal <-- $topic : Bag, $func : ValRedFuncRef, $identity : Universal)
This function is the same as sys.std.Set.reduction
, including that input values for the reduction come from the value
attribute of topic
, except that it works with a Bag
rather than a Set
; func
is invoked extra times, where both its v1
and v2
arguments might be different instances of the same value having >= 2 multiplicity.
sys.std.Bag.maybe_reduction
function sys.std.Bag.maybe_reduction (Maybe <-- $topic : Bag, $func : ValRedFuncRef)
This function is to sys.std.Set.maybe_reduction
as sys.std.Bag.reduction
is to sys.std.Set.reduction
.
sys.std.Bag.Set_from_Bag
function sys.std.Bag.Set_from_Bag (Set <-- $topic : Bag)
This function results in the Set
that is the projection of the value
attribute of its Bag
argument.
sys.std.Bag.Bag_from_Set
function sys.std.Bag.Bag_from_Set (Bag <-- $topic : Set)
This function results in the Bag
that is the extension of its Set
argument with a new count
attribute whose value for every tuple is 1.
sys.std.Bag.Bag_from_wrap
function sys.std.Bag.Bag_from_wrap (bag_of.Tuple <-- $topic : Relation)
This function results in a Bag
whose value
attribute is tuple-typed and that attribute's values are all the tuples of topic
; it is a short-hand for a relational wrap of all attributes of topic
such that the new tuple-valued attribute is named value
, and then that result is extended with a count
attribute whose value for every tuple is 1.
sys.std.Bag.Bag_from_cmpl_group
function sys.std.Bag.Bag_from_cmpl_group (bag_of.Tuple <-- $topic : Relation, $group_per : set_of.Name)
This function is like sys.std.Core.Relation.cardinality_per_group
but that the count_attr_name
is count
and all the other attributes that would have been in the result are wrapped in a single tuple-valued attribute named value
. This function is to cardinality_per_group
what sys.std.Array.Array_from_wrap
is to sys.std.Relation.rank
.
sys.std.Bag.Bag_from_attr
function sys.std.Bag.Bag_from_attr (Bag <-- $topic : Relation, $name : Name)
This function results in a Bag
consisting of all the values of the attribute of topic
named by name
. It is a short-hand for first doing a relational group on all attributes of topic
besides name
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 value
and count
respectively.
sys.std.Bag.is_subset
function sys.std.Bag.is_subset (Bool <-- $topic : Bag, $other : Bag)
This function is like sys.std.Core.Relation.is_subset
but that it accounts for the greater-than-one multiplicity of values in its arguments; this function returns Bool:true
iff the multiplicity of each topic
value is less than or equal to the multiplicity of its counterpart other
value.
sys.std.Bag.is_not_subset
function sys.std.Bag.is_not_subset (Bool <-- $topic : Bag, $other : Bag)
This function is like sys.std.Core.Relation.is_not_subset
as per is_subset
.
sys.std.Bag.is_superset
function sys.std.Bag.is_superset (Bool <-- $topic : Bag, $other : Bag)
This function is an alias for sys.std.Bag.is_subset
except that it transposes the topic
and other
arguments. This function is like sys.std.Core.Relation.is_superset
but that it accounts for the greater-than-one multiplicity of values in its arguments; this function returns Bool:true
iff the multiplicity of each topic
value is greater than or equal to the multiplicity of its counterpart other
value.
sys.std.Bag.is_not_superset
function sys.std.Bag.is_not_superset (Bool <-- $topic : Bag, $other : Bag)
This function is an alias for sys.std.Bag.is_not_subset
except that it transposes the topic
and other
arguments. This function is like sys.std.Core.Relation.is_not_superset
as per is_superset
.
sys.std.Bag.is_proper_subset
function sys.std.Bag.is_proper_subset (Bool <-- $topic : Bag, $other : Bag)
This function is like sys.std.Relation.is_proper_subset
as per is_subset
. TODO: What is its definition?
sys.std.Bag.is_not_proper_subset
function sys.std.Bag.is_not_proper_subset (Bool <-- $topic : Bag, $other : Bag)
This function is like sys.std.Relation.is_not_proper_subset
as per is_subset
. TODO: What is its definition?
sys.std.Bag.is_proper_superset
function sys.std.Bag.is_proper_superset (Bool <-- $topic : Bag, $other : Bag)
This function is an alias for sys.std.Bag.is_proper_subset
except that it transposes the topic
and other
arguments. This function is like sys.std.Relation.is_proper_superset
as per is_superset
.
sys.std.Bag.is_not_proper_superset
function sys.std.Bag.is_not_proper_superset (Bool <-- $topic : Bag, $other : Bag)
This function is an alias for sys.std.Bag.is_not_proper_subset
except that it transposes the topic
and other
arguments. This function is like sys.std.Relation.is_not_proper_superset
as per is_superset
.
sys.std.Bag.union
function sys.std.Bag.union (Bag <-- $topic : set_of.Bag)
This function is like sys.std.Core.Relation.union
but that it just looks at the value
attribute of its argument elements when determining what element tuples correspond; then for each tuple in the result, its count
attribute value is the maximum of the count
attribute values of its corresponding input element tuples.
sys.std.Bag.union_sum
function sys.std.Bag.union_sum (Bag <-- $topic : bag_of.Bag)
This function is like sys.std.Bag.union
but that for each pair of argument elements being unioned, the output count
value is the sum of the input count
values rather than being the maximum of the inputs.
sys.std.Bag.intersection
function sys.std.Bag.intersection (Bag <-- $topic : set_of.Bag)
This function is like sys.std.Core.Relation.intersection
as union
is like sys.std.Core.Relation.union
; the minimum of count
attribute values is used rather than the maximum.
sys.std.Bag.diff
function sys.std.Bag.diff (Bag <-- $source : Bag, $filter : Bag)
This function is like sys.std.Core.Relation.diff
as union
is like sys.std.Core.Relation.union
; for corresponding input tuples, the result only has a tuple with the same value
if the count
of the source
tuple is greater than the count
of the filter
tuple, and the count
of 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-2009, Muldis Data Systems, Inc.
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.