Leonardus
|
There is a collection of examples in the directory Examples
.
To run one of them in the shell, use:
../Examples> ../lb Hanoi.leo
All examples can be executed with:
make runxtest
To run one of them in the shell, use:
../Examples> lb Hanoi.leo
or by using the Linux shebang:
../Examples> ./Hanoi.leo
An example procedure to compare array contents.
This is not a deep comparison; the contents of the arrays are compared with the build-in eq operator.
This example demonstrates a prototype-based object (PTBO) to create a
a data type Complex.
The LeoScript EgyptianFraction demonstrates the representation of a rational
number in the interval [0,1] as a sum of unit fractions (fractions with numerator 1).
However, the computed representation is not always the shortest possible.
A simple example of how to implement one operator with others.
The enddict
procedure is equivalent to the >>
operator.
Demonstrates the usage of the Extended Euclidean Algorithm, implemented as xgcd
.
Factorial demonstrates the implemented 128-Bit integer size.
The definition of the factorial
procedure is a fragment from the Green Book.
Factors.leo
demonstrates a procedure factors
,
that generates a list of all factors of an integer X > 0 and places the list on the stack.
The list of the first 51 Fibonacci numbers.
Using the leodict algorithm with an exponentiation of the golden ratio.
A compact but inefficient recursive way to print the first 20 Fibonacci numbers.
(copied from Wikipedia). It also demonstrates a statistics snapshot at program end.
This script can be executed by Ghostscript, if one removes the shebang.
Hanoi.leo
demonstrates stack objects in a procedure hanoi
,
which solves the mathematical puzzle Tower of Hanoi recursively.
Demonstrates the approximation of pi with a simple
Monte Carlo simulation of random points within a circle.
This example demonstrates a prototype-based object (PTBO) encapsulation using the
calculation of measures of statistical dispersion in descriptive statistics.