The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Muldis::D::Core::Integer - Muldis D integer numeric operators

VERSION

This document is Muldis::D::Core::Integer version 0.101.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 essentially all of the core Muldis D operators that are specific to the core data type Int, essentially all the generic ones that a typical programming language should have.

This documentation is pending.

FUNCTIONS FOR INTEGER MATH

These functions implement commonly used integer numeric operations.

sys.std.Core.Integer.inc

function sys.std.Core.Integer.inc (Int <-- $topic : Int)

This function results in its argument incremented by 1. Note that this operation is also known as ++.

sys.std.Core.Integer.dec

function sys.std.Core.Integer.dec (Int <-- $topic : Int)

This function results in its argument decremented by 1. Note that this operation is also known as --.

sys.std.Core.Integer.abs

function sys.std.Core.Integer.abs (NNInt <-- $topic : Int)

This function results in the absolute value of its argument. Note that this operation is also known as I||.

sys.std.Core.Integer.sum

function sys.std.Core.Integer.sum (Int <-- $topic? : bag_of.Int)

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 topic has zero values, then sum results in the integer zero, which is the identity value for addition. Note that this operation is also known as addition or plus or I+.

sys.std.Core.Integer.diff

function sys.std.Core.Integer.diff (Int <-- $minuend : Int, $subtrahend : Int)

This function results in the difference when its subtrahend argument is subtracted from its minuend argument. Note that this operation is also known as subtraction or minus or I-.

sys.std.Core.Integer.abs_diff

function sys.std.Core.Integer.abs_diff (Int <-- $topic : Int, $other : Int)

This symmetric function results in the absolute difference between its 2 arguments. Note that this operation is also known as I|-|.

sys.std.Core.Integer.product

function sys.std.Core.Integer.product (Int <-- $topic? : bag_of.Int)

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 topic has zero values, then product results in the integer 1, which is the identity value for multiplication. Note that this operation is also known as multiply or times or I*.

sys.std.Core.Integer.quotient

function sys.std.Core.Integer.quotient (Int <-- $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. Note that this operation is also known as divide or I/.

sys.std.Core.Integer.remainder

function sys.std.Core.Integer.remainder (NNInt <-- $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. Note that this operation is also known as modulus or %.

sys.std.Core.Integer.quot_and_rem

function sys.std.Core.Integer.quot_and_rem (Tuple <-- $dividend : Int, $divisor : Int)

This function results in a binary tuple whose attribute names are quotient (an Int) and remainder (a NNInt) and whose respective attribute values are what sys.std.Core.Integer.quotient and sys.std.Core.Integer.remainder would result in when given the same arguments. This function will fail if divisor is zero.

sys.std.Core.Integer.maybe_quotient

function sys.std.Core.Integer.maybe_quotient (maybe_of.Int <-- $dividend : Int, $divisor : Int)

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

sys.std.Core.Integer.maybe_remainder

function sys.std.Core.Integer.maybe_remainder (maybe_of.NNInt <-- $dividend : Int, $divisor : Int)

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

sys.std.Core.Integer.maybe_quot_and_rem

function sys.std.Core.Integer.maybe_quot_and_rem (Relation <-- $dividend : Int, $divisor : Int)

This function results in a binary relation whose attribute names are quotient (an Int) and remainder (a NNInt). If divisor is nonzero then the result has a single tuple whose respective attribute values are what sys.std.Core.Integer.quotient and sys.std.Core.Integer.remainder would result in when given the same arguments; if divisor is zero, then the result has zero tuples.

sys.std.Core.Integer.range

function sys.std.Core.Integer.range (Int <-- $topic : set_of.Int)

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.

sys.std.Core.Integer.median

function sys.std.Core.Integer.median (set_of.Int <-- $topic : bag_of.Int)

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.

sys.std.Core.Integer.mode

function sys.std.Core.Integer.mode (set_of.Int <-- $topic : bag_of.Int)

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.

sys.std.Core.Integer.power

function sys.std.Core.Integer.power (Int <-- $radix : Int, $exponent : NNInt)

This function results in its radix argument taken to the power of its (non-negative integer) exponent argument. This function will result in 1 if radix and exponent are both zero (rather than failing), which seems reasonable given that the Integer.power function strictly has no numeric continuity (unlike Rational.power) and that this is by far the most common practice in both pure integer math contexts and computer languages, including SQL. Note that this operation is also known as exponentiation or I^.

sys.std.Core.Integer.factorial

function sys.std.Core.Integer.factorial (PInt <-- $topic : NNInt)

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). Note that this operation is also known as I!.

SYSTEM-SERVICES FOR RANDOM NUMBER GENERATORS

These system-service routines provide ways to get random numbers from the system. Where the results are in the range between truly random and pseudo-random is, for the moment, an implementation detail, but the details of these functions is subject to become more formalized later.

sys.std.Core.Integer.fetch_random

system-service sys.std.Core.Integer.fetch_random (&$target : Int, $interval : interval_of.Int)

This system-service routine will update the variable supplied as its target argument so that it holds a randomly generated integer value that is included within the interval defined by its interval argument. This function will fail if interval represents an empty interval.

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-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.