NAME

Muldis::D::Core::Set - Muldis D Set and Maybe specific operators

VERSION

This document is Muldis::D::Core::Set version 0.128.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. Moreover, you should read the Muldis::D::Core document before this current document, as that forms its own tree beneath a root document branch.

DESCRIPTION

This document describes generic operators that are specific to the Set and Maybe parameterized relation types, and said operators are short-hands for more generic relational operators.

This documentation is pending.

GENERIC RELATIONAL FUNCTIONS FOR SETS

sys.std.Core.Set.has_member

function sys.std.Core.Set.has_member (Bool <-- $set : Set, $value : Universal) {...}

This function results in Bool:True iff its value argument matches the sole attribute of a tuple of its set argument (that is, iff conceptually value is a member of set), and Bool:False otherwise. This function will warn if its 2 arguments are incompatible as per sys.std.Core.Relation.is_subset. Note that this operation is also known as s∋ or s-has.

sys.std.Core.Set.has_not_member

function sys.std.Core.Set.has_not_member (Bool <-- $set : Set, $value : Universal) {...}

This function is exactly the same as sys.std.Core.Set.has_member except that it results in the opposite boolean value when given the same arguments. Note that this operation is also known as s∌ or s-!has or s-not-has.

sys.std.Core.Set.value_is_member

function sys.std.Core.Set.value_is_member (Bool <-- $value : Universal, $set : Set) {...}

This function is an alias for sys.std.Core.Set.has_member. This function results in Bool:True iff its value argument matches the sole attribute of a tuple of its set argument (that is, iff conceptually value is a member of set), and Bool:False otherwise. Note that this operation is also known as ∈s or in-s.

sys.std.Core.Set.value_is_not_member

function sys.std.Core.Set.value_is_not_member (Bool <-- $value : Universal, $set : Set) {...}

This function is an alias for sys.std.Core.Set.has_not_member. This function is exactly the same as sys.std.Core.Set.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 ¬in;s or !in-s or not-in-s.

sys.std.Core.Set.insertion

function sys.std.Core.Set.insertion (Set <-- $set : Set, $value : Universal) {...}

This function results in a Set that is the relational union of set and a Set whose sole tuple has the sole attribute value of value; that is, conceptually the result is value inserted into set. As a trivial case, if value already exists in set, then the result is just set.

sys.std.Core.Set.disjoint_ins

function sys.std.Core.Set.disjoint_ins (Set <-- $set : Set, $value : Universal) {...}

This function is exactly the same as sys.std.Core.Set.insertion except that it will fail if value already exists in set.

sys.std.Core.Set.deletion

function sys.std.Core.Set.deletion (Set <-- $set : Set, $value : Universal) {...}

This function results in a Set that is the relational difference from set of a Set whose sole tuple has the sole attribute value of value; that is, conceptually the result is value deleted from set. As a trivial case, if value already doesn't exist in set, then the result is just set.

sys.std.Core.Set.reduction

function sys.std.Core.Set.reduction (Universal <-- $topic : Set, $func : ValRedCFuncNC, $identity : Universal) {...}

This function is a generic reduction operator that recursively takes each pair of input values in topic and applies an argument-specified scalar or nonscalar value-resulting value-reduction function (which is both commutative and associative) to the pair until just one input value is left, which is the result. The value-reduction function to apply is named in the func argument, and that function must have 2 parameters named v1 and v2, which take the 2 input scalar or nonscalar values for an invocation. If topic has zero values, then reduction results in the value given in identity. Note that identity may be changed to take a function name rather than a value, for consistency with func. This function will fail|warn if the |declared type of identity isn't a subtype of the |declared type of the sole attribute of topic.

sys.std.Core.Set.Set_from_wrap

function sys.std.Core.Set.Set_from_wrap (set_of.Tuple <-- $topic : Relation) {...}

This function results in a Set whose sole attribute is tuple-typed and the attribute values are all the tuples of topic; is a short-hand for a relational wrap of all attributes of topic such that the new tuple-valued attribute is named value.

sys.std.Core.Set.Set_from_attr

function sys.std.Core.Set.Set_from_attr (Set <-- $topic : Relation, $name : Name) {...}

This function results in a Set consisting of all the values of the attribute of topic named by name. It is a short-hand for a unary projection of just the named attribute plus its renaming to value.

GENERIC RELATIONAL FUNCTIONS FOR MAYBES

sys.std.Core.Set.Maybe.Nothing

function sys.std.Core.Set.Maybe.Nothing (Maybe <--) {...}

This named-value selector function results in the only zero-tuple Maybe value, which is known by the special name Maybe:Nothing, aka Nothing, aka empty set aka .

sys.std.Core.Set.Maybe.single

function sys.std.Core.Set.Maybe.single (Single <-- $value : Universal) {...}

This selector function results in the Maybe value with a single tuple whose value attribute's value is the value argument. Note that this operation is also known as s.

sys.std.Core.Set.Maybe.attr

function sys.std.Core.Set.Maybe.attr (Universal <-- $topic : Single) {...}

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 Single. Note that this operation is also known as v.

sys.std.Core.Set.Maybe.attr_or_default

function sys.std.Core.Set.Maybe.attr_or_default (Universal <-- $topic? : array_of.Maybe, $default : APTypeNC) {...}

This function results in the scalar or nonscalar value of the sole attribute of the sole tuple of the lowest-indexed of its N topic input element values where said element isn't equal to Nothing, 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 default argument. This function is a short-hand for invoking attr_or_value with the result from invoking sys.std.Core.Universal.default. Note that this operation is also known as //d.

sys.std.Core.Set.Maybe.attr_or_value

function sys.std.Core.Set.Maybe.attr_or_value (Universal <-- $topic? : array_of.Maybe, $value : Universal) {...}

This function results in the scalar or nonscalar value of the sole attribute of the sole tuple of the lowest-indexed of its N topic input element values where said element isn't equal to Nothing, if there is such an element, and otherwise it results in value. This function will warn if the declared type of value isn't a subtype of the declared type of the attribute. Note that this operation is also known as //. In situations where a Maybe is used analogously to a SQL nullable value, this function is analogous to the N-adic SQL COALESCE function.

sys.std.Core.Set.Maybe.order

function sys.std.Core.Set.Maybe.order (Order <-- $topic : Maybe, $other : Maybe, $S_ord_func? : OrdDetCFuncNC, $S_is_reverse_order? : Bool, $N_is_after_all_S : Bool, $is_reverse_order? : Bool) {...}

This function is a generic (total) order-determination function for Maybe values. Iff both of its topic and other arguments are identical, this function results in Order:Same. Otherwise, iff both of those 2 arguments are Single values, then the result of this function is the result of applying to those 2 arguments the (total) order-determination function given in its S_ord_func argument, as curried by its S_is_reverse_order argument; to be specific, the order-determination function takes the attribute values of topic and other, not the whole Single values. Otherwise, iff topic is Nothing, this function results in Order:Increase or Order:Decrease respectively when N_is_after_all_S is Bool:False (the default) or Bool:True. Otherwise (iff other is Nothing), this function results in the reverse of when only topic is Nothing. The is_reverse_order argument is applied to the result of this function after all of the other arguments are applied; if it is Bool:False, it does not change the result; if it is Bool:True, then it reverses the result. In situations where a Maybe is used analogously to a SQL nullable value and this function is analogous to the dyadic comparison underlying a SQL "ORDER BY", then S_is_reverse_order designates SQL's "ASC|DESC" and N_is_after_all_S designates SQL's "NULLS FIRST|LAST".

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 (darren@DarrenDuncan.net)

LICENSE AND COPYRIGHT

This file is part of the formal specification of the Muldis D language.

Muldis D is Copyright © 2002-2010, 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.