Next: Algebraic types Up: Implementing Computer Algebra with ALDOR Previous: Implementing Computer Algebra with ALDOR

## Fundamental types

The libaldor library is a general library for programming with ALDOR with no emphasis on symbolics or numerical computations.
Numbers: machine integers and floats, long integers and floats (ALDOR and GMP).
Input/Output: strings, files, binary I/O-streams, text I/O-streams
Data structures: arrays, lists, hash-tables, streams, ...
Tools: debugging, profiling, exceptions.
Here are some fundamental types provided by libaldor:
define PrimitiveType: Category == with {
=: (%, %) -> Boolean;
~=: (%, %) -> Boolean;
}

define AdditiveType: Category == with {
0: %;
+: (%, %) -> %;
-: % -> %;
-: (%, %) -> %;
add!: (%, %) -> %;
minus!: % -> %;
minus!: (%, %) -> %;
zero?: % -> Boolean;
}

define ArithmeticType: Category == with {
1: %;
*: (%, %) -> %;
^: (%, MachineInteger) -> %;
commutative?: Boolean;
one?: % -> Boolean;
times!: (%, %) -> %;
}

The categories AdditiveType and ArithmeticType look like the definition of an abelian monoid and a ring. But in fact they only assert the existence of arithmetic operations without asserting algebraic properties such as commutativity, associativity, etc. This is needed for these sets of numbers (machine integers, floats) that do not have algebraic properties. If we look at the definition of MachineInteger in the interprter mode of ALDOR we get
%2 >> MachineInteger
() @ Join(
PrimitiveType with
0: %
1: %
bytes: MachineInteger
coerce: SInt -> %
coerce: % -> SInt
integer: Literal -> %
min: %
max: %
odd?: % -> Boolean
zero?: % -> Boolean
,
Join(CopyableType, IntegerType) with
mod+: (%, %, %) -> %
mod-: (%, %, %) -> %
mod*: (%, %, %) -> %
mod/: (%, %, %) -> %
mod^: (%, %, %) -> %
modInverse: (%, %) -> %
export to IntegerSegment(%)