NAME

Language::MuldisD::Ext::Integer - Muldis D extension for integer data types and operators

VERSION

This document is Language::MuldisD::Ext::Integer version 0.20.0.

PREFACE

This document is part of the Muldis D language specification, whose root document is Language::MuldisD; 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 Integer document describes the system-defined Muldis D Integer Extension, which consists of integer data types and operators, essentially all the generic ones that a typical programming language should have, but for the bare minimum needed for bootstrapping Muldis D, which are defined in the language core instead.

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 Language::MuldisD::Core.

This documentation is pending.

TYPE SUMMARY

Also for convenience are the regular set|maybe|seq|bag types sys.Integer.Spec.(Set|Maybe|Seq|Bag)Of(Int|UInt).

This documentation is pending.

SYSTEM-DEFINED INTEGER-CONCERNING DATA TYPES

sys.Integer.Spec.(Set|Maybe|Seq|Bag)Of(Int|UInt)

A (Set|Maybe|Seq|Bag)Of(Int|UInt) is a completely defined proper subtype of (Set|Maybe|Seq|Bag) whose value attribute has a declared type of a (Int|UInt) subtype.

SYSTEM-DEFINED INTEGER-CONCERNING FUNCTIONS

These functions implement commonly used integer numeric operations.

function sys.Integer.Int.increment result Int params { topic(Int) }

This function results in its argument incremented by 1.

function sys.Integer.Int.decrement result Int params { topic(Int) }

This function results in its argument decremented by 1.

function sys.Integer.Int.abs result UInt params { topic(Int) }

This function results in the absolute value of its argument.

function sys.Integer.Int.sum result Int params { addends(BagOfInt) }

This function results in the sum of the N element values of its argument; it is a reduction operator that recursively takes each pair of input values and adds (which is both commutative and associative) them together until just one is left, which is the result. If addends has zero values, then sum results in the integer zero, which is the identity value for addition.

function sys.Integer.Int.difference result Int params { minuend(Int), subtrahend(Int) }

This function results in the difference when its subtrahend argument is subtracted from its minuend argument.

function sys.Integer.Int.product result Int params { factors(BagOfInt) }

This function results in the product of the N element values of its argument; it is a reduction operator that recursively takes each pair of input values and multiplies (which is both commutative and associative) them together until just one is left, which is the result. If factors has zero values, then product results in the integer 1, which is the identity value for multiplication.

function sys.Integer.Int.quotient result Int params { dividend(Int), divisor(Int) }

This function results in the quotient when its dividend argument is divided by its divisor argument using integer division. This function will fail if divisor is zero.

function sys.Integer.Int.remainder result UInt params { dividend(Int), divisor(Int) }

This function results in the remainder when its dividend argument is divided by its divisor argument using integer division. This function will fail if divisor is zero.

function sys.Integer.Int.maybe_quotient result MaybeOfInt params { dividend(Int), divisor(Int) }

This function is exactly the same as sys.Integer.Int.quotient except that it results in a Maybe of what is otherwise the result, and that result has zero elements if divisor is zero.

function sys.Integer.Int.maybe_remainder result MaybeOfUInt params { dividend(Int), divisor(Int) }

This function is exactly the same as sys.Integer.Int.remainder except that it results in a Maybe of what is otherwise the result, and that result has zero elements if divisor is zero.

function sys.Integer.Int.range result Int params { topic(SetOfInt) }

This function results in the difference between the lowest and highest element values of its argument. If topic has zero values, then range results in the integer zero.

function sys.Integer.Int.median result SetOfInt params { topic(BagOfInt) }

This function results in the 1 or 2 median values of the N element values of its argument; they are returned as a set. It is equivalent to first arranging the input values from least to greatest, and then taking the single middle value, if the count of input values is odd, or taking the 2 middle values, if the count of input values is even (but if the 2 middle values are the same value, the output has one element). If topic has zero values, then the result set is empty.

function sys.Integer.Int.mode result SetOfInt params { topic(BagOfInt) }

This function results in the mode of the N element values of its argument; it is the set of values that appear the most often as input elements, and all have the same count of occurrances. As a trivial case, if all input elements have the same count of occurrances, then they will all be in the output. If topic has zero values, then the result set is empty.

function sys.Integer.Int.power result Int params { radix(Int), exponent(UInt) }

This function results in its radix argument taken to the power of its (unsigned integer) exponent argument. This function will fail if radix and exponent are both zero.

function sys.Integer.Int.factorial result PInt params { topic(UInt) }

This function results in the factorial of its argument (it is defined for an argument of zero to result in 1, as per the identity value for multiplication of an empty set).

These functions convert between Int values and canonically formatted representations of integers as character strings.

function sys.Integer.Int.Int_from_NEText result Int params { text(NEText), radix(Cat.PInt2_36) }

This selector function results in the Int value that its text argument maps to when the whole character string is evaluated as a base-radix integer. Extending the typical formats of [base-2, base-8, base-10, base-16], this function supports base-2 through base-36; to get the latter, the characters 0-9 and A-Z represent values in 0-35. This function will fail if text can't be mapped as specified.

function sys.Integer.Int.NEText_from_Int result NEText params { int(Int), radix(Cat.PInt2_36) }

This selector function results in the NEText value where its int argument is formatted as a base-radix integer.

These functions convert between Int values and canonically formatted representations of integers as binary strings. Conjecture: These may not actually be useful, and perhaps only operators that take an argument specifying a fixed-length field size, with big and little endian versions, would be appropriate instead. Or maybe both kinds are necessary.

function sys.Integer.Int.Int_from_Blob_S_VBE result Int params { blob(NEBlob) }

This selector function results in the Int value that its blob argument maps to when the whole bit string is treated literally as a variable-length binary (two's complement) signed integer of 1 or more bits in length. The first bit is taken as the sign bit, and any other bits provide greater precision than the -1 thru 0 range. The bit string is assumed to be big-endian, since it may not be possible to use little-endian in situations where the bit length isn't a multiple of 8.

function sys.Integer.Int.Blob_S_VBE_from_Int result NEBlob params { int(Int) }

This selector function results in the Blob value where its int argument is formatted as a variable-length binary (two's complement) signed integer of 1 or more bits in length; the smallest number of bits necessary to store int is used.

function sys.Integer.Int.Int_from_Blob_U_VBE result UInt params { blob(NEBlob) }

This function is the same as sys.Integer.Int.Int_from_Blob_S_VBE but that it does unsigned integers.

function sys.Integer.Int.Blob_U_VBE_from_Int result UInt params { blob(NEBlob) }

This function is the same as sys.Integer.Int.Blob_S_VBE_from_Int but that it does unsigned integers.

SEE ALSO

Go to Language::MuldisD for the majority of distribution-internal references, and Language::MuldisD::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 Language::MuldisD for details.

ACKNOWLEDGEMENTS

The ACKNOWLEDGEMENTS in Language::MuldisD apply to this file too.

2 POD Errors

The following errors were encountered while parsing the POD:

Around line 51:

'=item' outside of any '=over'

Around line 57:

You forgot a '=back' before '=head1'