1.2.8Class Integer

Integer type basic object model metaclass.

Class Integer from \
                 BOM( )
Methods
downtoRepeats a function or a sequence until the lower limit is reached.
ptrReturns the value itself.
timesrepeats a sequence a given number of times.
uptoRepeats a function or a sequence until the upper limit is reached.
Methods inherited from class BOM
__addOverrides binary addition operand.
__callOverrides call operator "self()".
__decOverrides decrement unary prefix operand.
__decpostOverrides decrement unary postfix operand.
__divOverrides binary division operand.
__getIndexOverrides array access operator []
__incOverrides increment unary prefix operand.
__incpostOverrides increment unary postifx operand.
__modOverrides modulo operand.
__mulOverrides binary multiplication operand.
__powOverrides power operand.
__setIndexOverrides array write operator []
__subOverrides binary subtraction operand.
baseClassReturns the class item from which an object has been instantiated.
boundDetermines if an item is bound or not.
classNameReturns the name of the class an instance is instantiated from.
clonePerforms a deep copy of the item.
comparePerforms a lexicographical comparison.
derivedFromChecks if this item has a given parent.
describeReturns the deep contents of an item on a string representation.
isCallableDetermines if an item is callable.
lenRetrieves the length of a collection
metaclassReturns the metaclass associated with this item.
ptrReturns a raw memory pointer out of this data (as an integer).
serializeSerialize the item on a stream for persistent storage.
toStringCoverts the object to string.
typeIdReturns an integer indicating the type of this item.

Methods

downto

Repeats a function or a sequence until the lower limit is reached.

Integer.downto( llimit, sequence )
llimit The lower limit of the loop.
sequence The sequence or function to be repeated.
ReturnThe last index processed.

This method repeats a loop from this integer down to the limit value included. If the limit is greater than this integer, the function returns immediately.

If the sequence is a function, then it is called iteratively with the current index value as last parameter. If it is a sequence, it is functionally evaluated and the &1 parametric binding is set to the index.


       5.downto( 2, printl )
       3.downto(0, .[printl "Value number " &1])

In both cases, returning an oob(0) will cause the loop to terminate, while returning an oob(1) from any evaluation in the sequence makes the rest of the evaluation to be skipped and the loop to be restarted.

ptr

Returns the value itself.

Integer.ptr()
ReturnThe value in this integer.

Falcon integers can be used to store memory locations, as the are granted to be wide at least as the widest pointer on the target platform. For this reason, they can be used to transport raw pointers coming from external libraries.

This function override ensures that .ptr() applied to an integer returns the original integer value (and doesn't get mangled as with other ptr overrides).

times

repeats a sequence a given number of times.

Integer.times( sequence )
sequence Function or sequence to be repeated.
ReturnLast index processed.

This method works exactly as the times function when the first parameter is a number.

See also: times.

upto

Repeats a function or a sequence until the upper limit is reached.

Integer.upto( llimit, sequence )
llimit The upper limit of the loop.
sequence The sequence or function to be repeated.
ReturnThe last index processed.

This method repeats a loop from this integer down to the limit value included. If the limit is less than this integer, the function returns immediately.

If the sequence is a function, then it is called iteratively with the current index value as last parameter. If it is a sequence, it is functionally evaluated and the &1 parametric binding is set to the index.


       2.upto( 5, printl )
       2.downto(5, .[printl "Value number " &1])

In both cases, returning an oob(0) will cause the loop to terminate, while returning an oob(1) from any evaluation in the sequence makes the rest of the evaluation to be skipped and the loop to be restarted.

Made with http://www.falconpl.org