=pod =encoding utf8 =head1 NAME Muldis::D::Ext::Set - Muldis D extension for Set and Maybe specific operators =head1 VERSION This document is Muldis::D::Ext::Set version 0.79.1. =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. =head1 DESCRIPTION Muldis D has a mandatory core set of system-defined (eternally available) entities, which is referred to as the I or the I; 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 I, are non-mandatory and are defined in terms of the core or each other, but the reverse isn't true. This current C document describes the system-defined I, which consists of generic operators that are specific to the C and C parameterized relation types, 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 L. I =head1 SYSTEM-DEFINED SET-CONCERNING FUNCTIONS Each C parameter is optional and defaults to the zero-attribute tuple if no explicit argument is given to it. =head2 sys.std.Set.has_member C<< function sys.std.Set.has_member (Bool <-- Set $set, Universal $value) >> This function results in C iff its C argument matches the sole attribute of a tuple of its C argument (that is, iff conceptually C is a member of C), and C otherwise. This function will warn if its 2 arguments are incompatible as per C. Note that this operation is also known as C. =head2 sys.std.Set.has_not_member C<< function sys.std.Set.has_not_member (Bool <-- Set $set, Universal $value) >> This function is exactly the same as C except that it results in the opposite boolean value when given the same arguments. Note that this operation is also known as C. =head2 sys.std.Set.value_is_member C<< function sys.std.Set.value_is_member (Bool <-- Universal $value, Set $set) >> This function is an alias for C. This function results in C iff its C argument matches the sole attribute of a tuple of its C argument (that is, iff conceptually C is a member of C), and C otherwise. Note that this operation is also known as C. =head2 sys.std.Set.value_is_not_member C<< function sys.std.Set.value_is_not_member (Bool <-- Universal $value, Set $set) >> 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. Note that this operation is also known as C. =head2 sys.std.Set.insertion C<< function sys.std.Set.insertion (Set <-- Set $set, Universal $value) >> This function results in a C that is the relational union of C and a Set whose sole tuple has the sole attribute value of C; that is, conceptually the result is C inserted into C. As a trivial case, if C already exists in C, then the result is just C. =head2 sys.std.Set.disjoint_ins C<< function sys.std.Set.disjoint_ins (Set <-- Set $set, Universal $value) >> This function is exactly the same as C except that it will fail if C already exists in C. =head2 sys.std.Set.deletion C<< function sys.std.Set.deletion (Set <-- Set $set, Universal $value) >> This function results in a C that is the relational difference from C of a Set whose sole tuple has the sole attribute value of C; that is, conceptually the result is C deleted from C. As a trivial case, if C already doesn't exist in C, then the result is just C. =head2 sys.std.Set.reduction C<< function sys.std.Set.reduction (Universal <-- Set $topic, ValRedFuncRef $func, Tuple $assuming?, Universal $identity) >> This function is a generic reduction operator that recursively takes each pair of input values in C and applies an argument-specified scalar or nonscalar value-resulting C function (which is both commutative and associative) to the pair until just one input value is left, which is the result. The C function to apply is named in the C argument, and that function must have 3 arguments named C, C, C; the last parameter is curried with the same-named argument of C, and the first 2 parameters are the 2 input scalar or nonscalar values for an invocation. If C has zero values, then C results in the value given in C. I may be changed to take a function name rather than a value, for consistency with C.> This function will fail|warn if the |declared type of C isn't a subtype of the |declared type of the sole attribute of C. =head2 sys.std.Set.maybe_reduction C<< function sys.std.Set.maybe_reduction (Maybe <-- Set $topic, ValRedFuncRef $func, Tuple $assuming?) >> This function is exactly the same as C except that it does not take an C argument, and it results in a C of what is otherwise the result type, and that result has zero elements if the argument has zero elements. =head2 sys.std.Set.Set_from_wrap C<< function sys.std.Set.Set_from_wrap (set_of.Tuple <-- Relation $topic) >> This function results in a C whose sole attribute is tuple-typed and the attribute values are all the tuples of C; is a short-hand for a relational wrap of all attributes of C such that the new tuple-valued attribute is named C. =head2 sys.std.Set.Set_from_attr C<< function sys.std.Set.Set_from_attr (Set <-- Relation $topic, 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 a unary projection of just the named attribute plus its renaming to C. =head1 SYSTEM-DEFINED MAYBE-CONCERNING FUNCTIONS =head2 sys.std.Set.Maybe.nothing C<< function sys.std.Set.Maybe.nothing (Maybe <--) >> This C selector function results in the only zero-tuple Maybe value, which is known by the special name C, aka C, aka I aka C<∅>. =head2 sys.std.Set.Maybe.single C<< function sys.std.Set.Maybe.single (Single <-- Universal $value) >> This selector function results in the Maybe value with a single tuple whose C attribute's value is the C argument. Note that this operation is also known as C. =head2 sys.std.Set.Maybe.attr C<< function sys.std.Set.Maybe.attr (Universal <-- Single $topic) >> This function results in the scalar or nonscalar value of the sole attribute of the sole tuple of its argument, which always exists when the argument is a C. Note that this operation is also known as C. =head2 sys.std.Set.Maybe.attr_or_default C<< function sys.std.Set.Maybe.attr_or_default (Universal <-- array_of.Maybe $topic?, TypeRef $default) >> This function results in the scalar or nonscalar value of the sole attribute of the sole tuple of the lowest-indexed of its N C input element values where said element isn't equal to C, if there is such an element; otherwise, it results in the default value of the scalar or nonscalar data type whose name is given in the C argument. This function is a short-hand for invoking C with the result from invoking C. Note that this operation is also known as C. =head2 sys.std.Set.Maybe.attr_or_value C<< function sys.std.Set.Maybe.attr_or_value (Universal <-- array_of.Maybe $topic?, Universal $value) >> This function results in the scalar or nonscalar value of the sole attribute of the sole tuple of the lowest-indexed of its N C input element values where said element isn't equal to C, if there is such an element, and otherwise it results in C. This function will warn if the declared type of C isn't a subtype of the declared type of the attribute. Note that this operation is also known as C. In situations where a C is used analagously to a SQL nullable value, this function is analagous to the N-adic SQL COALESCE function. =head2 sys.std.Set.Maybe.order C<< function sys.std.Set.Maybe.order (Order <-- Maybe $topic, Maybe $other, Bool $treat_nothing_as_max, OrdDetFuncRef $ord_func?, Tuple $ord_assuming?, Bool $reverse_order_of_singles?) >> This function is a generic (total) C function for C values. Iff both of its C and C arguments are identical, this function results in C. Otherwise, iff both of those 2 arguments are C values, then the result of this function is the result of applying to those 2 arguments the (total) C function given in its C argument, as curried by its C and C arguments. Otherwise, iff C is C, this function results in C or C respectively when C is C (the default) or C. Otherwise (iff C is C), this function results in the reverse of when only C is C. In situations where a C is used analagously to a SQL nullable value and this function is analagous to the dyadic comparison underlying a SQL "ORDER BY", then C designates SQL's "ASC|DESC" and C designates SQL's "NULLS FIRST|LAST". =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-2009, 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