=pod =encoding utf8 =head1 NAME Muldis::D::Core::Ordered - Muldis D generic ordered-sensitive operators =head1 VERSION This document is Muldis::D::Core::Ordered 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 essentially all of the core Muldis D ordered-sensitive operators, essentially all the generic ones that a typical programming language should have. I =head1 VIRTUAL FUNCTIONS FOR THE ORDERED MIXIN TYPE Rather than having a whole set of virtual functions for the C mixin, such as before/after/min/max/between/etc, we have just the one C for each ordered type to implement, and then all the other ordered-sensitive routines (before/etc) just wrap the virtual C. =head2 sys.std.Core.Ordered.order C<< function order (Order <-- topic@ : Ordered, other@ : Ordered, misc_args? : Tuple, is_reverse_order? : Bool) {...} >> This virtual (total) C function results in C iff its C and C arguments are exactly the same value, and otherwise it results in C if the value of the C argument is considered to be an increase (as defined by the implementing function) over the value of the C argument, and otherwise it results in C as the reverse of the last condition would be true. This function will fail if its C and C arguments are not values of a common ordered type for which an C function is defined that explicitly implements this function. Note that C functions are considered the only fundamental order-sensitive operators, and all others are defined over them. This function also has a C-typed third parameter, named C, which carries optional customization details for the order-determination algorithm; this permits the function to implement a choice between multiple (typically similar) ordering algorithms rather than just one, which reduces the number of functions needed for supporting that choice; if the algorithm is not customizable, then a tuple argument would be of degree zero. This function also has a C-typed fourth parameter, named C; a C argument means the function's algorithm operates as normal when given any particular 3 other arguments (meaning a sorting operation based on it will place elements in ascending order), while a C argument means the function's algorithm operates in reverse, so the function results in the reverse C value it would have otherwise when given the same 3 other arguments (meaning a sorting operation based on it will place elements in descending order). The C and C parameters are optional and default to the zero-attribute tuple and C, respectively, if no explicit arguments are given to them. =head1 VIRTUAL FUNCTIONS FOR THE ORDINAL MIXIN TYPE Conceivably, the C mixin could come with functions like I or I, since such are common practice for ordinal types in other languages or contexts, to complement the C and C functions, providing the basis to take an C type and enumerate all of its values. However, that common practice is generally based in contexts where all ordinal types are finite, such as a "32 bit integer" type. In Muldis D, there is no requirement for an C-composing type to be finite, and at least 1 system-defined ordinal type, C, is instead unlimited, and there is no concept of a first or last C that can be counted from. Therefore, C has no I or I, and if you want to enumerate an ordinal type's values, the canonical means to do so is to start with that type's I value instead, which the system-defined C function provides; starting with the default value, you can reach all values of any ordinal Muldis D type eventually, enumerating your way to them in sequence using either C to go earlier and C to go later, for any arbitrary distance along the ordinal type's value line. I =head2 sys.std.Core.Ordered.Ordinal.pred C<< function pred (Ordinal <-- topic@ : Ordinal) {...} >> This virtual function results in the value that precedes its argument, iff the argument has a preceding value according to the C-composing type of the argument; otherwise, this virtual function results in the singleton value C<-Inf> (negative infinity), which can be tested for to know you've run out of values. Note that this operation is also known as C<-->. =head2 sys.std.Core.Ordered.Ordinal.succ C<< function succ (Ordinal <-- topic@ : Ordinal) {...} >> This virtual function results in the value that succeeds its argument, iff the argument has a succeeding value according to the C-composing type of the argument; otherwise, this virtual function results in the singleton value C (positive infinity), which can be tested for to know you've run out of values. Note that this operation is also known as C<++>. =head1 GENERIC ORDERED-SENSITIVE FUNCTIONS FOR ALL DATA TYPES These are generic operators that are sensitive to an ordering of a type's values, and are used for such things as list sorting or quota queries or determining before/after/min/max/between/etc. They can potentially be used with values of any data type as long as said data type has a (total) C function defined for it, and all system-defined conceptually-ordered Muldis D scalar root types do. Each of these functions is a wrapper over the C function named C when the latter function is curried by a C argument of C and by a calling-function-specific C argument value. =head2 sys.std.Core.Ordered.is_before C<< function is_before (Bool <-- topic : Ordered, other : Ordered) {...} >> This function results in C iff C would result in C when given the same corresponding 2 arguments plus an C argument of C, and C otherwise. Note that this operation is also known as I or C<< < >>. =head2 sys.std.Core.Ordered.is_after C<< function is_after (Bool <-- topic : Ordered, other : Ordered) {...} >> This function is an alias for C except that it transposes the C and C arguments. This function results in C iff C would result in C when given the same corresponding 2 arguments plus an C argument of C, and C otherwise. Note that this operation is also known as I or C<< > >>. =head2 sys.std.Core.Ordered.is_before_or_same C<< function is_before_or_same (Bool <-- topic : Ordered, other : Ordered) {...} >> This function is exactly the same as C except that it results in C if its 2 primary arguments are identical. Note that this operation is also known as I or C<≤>. =head2 sys.std.Core.Ordered.is_after_or_same C<< function is_after_or_same (Bool <-- topic : Ordered, other : Ordered) {...} >> This function is an alias for C except that it transposes the C and C arguments. This function is exactly the same as C except that it results in C if its 2 primary arguments are identical. Note that this operation is also known as I or C<≥>. =head2 sys.std.Core.Ordered.min C<< function min (Ordered <-- topic : set_of.Ordered) {...} >> This function is a reduction operator that recursively takes each pair of its N input element values and picks the minimum of the 2 (which is commutative, associative, and idempotent) until just one is left, which is the function's result. If C has zero values, then C results in the singleton value C (positive infinity), which is the identity value for C. =head2 sys.std.Core.Ordered.max C<< function max (Ordered <-- topic : set_of.Ordered) {...} >> This function is exactly the same as C except that it results in the maximum input element value rather than the minimum one, and that C's identity value is C<-Inf> (negative infinity). =head2 sys.std.Core.Ordered.minmax C<< function minmax (Tuple <-- topic : set_of.Ordered) {...} >> This function results in a binary tuple whose attribute names are C and C and whose respective attribute values are what C and C would result in when given the same arguments. =head1 VIRTUAL UPDATERS FOR THE ORDINAL MIXIN TYPE =head2 sys.std.Core.Ordered.Ordinal.assign_pred C This update operator is a short-hand for first invoking the C function with the same argument, and then assigning the result of that function to its argument. Note that this operation is also known as C<:=-->. =head2 sys.std.Core.Ordered.Ordinal.assign_succ C This update operator is a short-hand for first invoking the C function with the same argument, and then assigning the result of that function to its argument. Note that this operation is also known as 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