Leonardus
Loading...
Searching...
No Matches
USING

There are three main ways to get started with Leonardus:

  • Consult the project's help pages
  • Use the published Docker images leonardus or leojupyter
  • Compile the programs yourself

Help

For detailed documentation consult the project's GitLab Pages. There you can find the latest user and developer information including content
extracted from the source code files.

Alternatively, you can find it in the Docker image leonardus under
/usr/local/share/doc/leonardus/.

To get command-line help, type:

  • lc -h (for the calculator)
  • lb -h (for the LeoScript interpreter)

either within the Docker image or after building the project.

Man Pages

Leonardus integrates the traditional UNIX man page subsystem.

Usage examples:

man RAD
man 7 __odo
man nip
man Forth::over
man -- -rot
whatis atan
whatis nip
apropos odo
apropos Forth
apropos "Vocabulary Forth"
apropos LeoScript
apropos -s 7 ]

Docker Preparation

The GitLab CI/CD pipelines automatically build and publish Docker images to
Docker hub. You get quick access to a ready-to-run Leonardus installation by
using them.

As prerequisites you need a running Docker environment. In the following
documentation we additionally assume, the you configured your environment to
allow docker commands run as your login user. This can usually be accomplished
by adding your login user to the "docker" group:

sudo usermod -aG docker ${USER}

Docker Image "leonardus"

Pull the image hagenbund2/leonardus and start it:

docker run -it \-\-rm hagenbund2/leonardus:latest

The CLI applications lc and lb will be available in the opening shell.
lb runs LeoScripts. lc serves as command line calculator.

Follow the hints on the welcome screen.

Extra

As a Docker feature, you could even execute lc in one line with e.g.:

docker run \-\-rm hagenbund2/leonardus lc 41 1 add

With a shell alias,

alias lcc='docker run \-\-rm hagenbund2/leonardus lc'

you get:

lcc 25346 95095 gcd

Run the Image As Your Login User

The previous command line

docker run -it \-\-rm hagenbund2/leonardus:latest

runs the image as root user on your system. For better integration with you
home directory data leonardus can be executed with you login user.

Consult the Tools/udocker.sh script from the GitLab repository.

With it, you can map your home directory into the image to get persistancy of
LeoScripts and data.

Docker Image "leojupyter"

Leonardus integrates with JupyterLab by serving as so called Jupyter kernel.
The leojupyter Docker image contains

  • a JupyterLab installation
  • the Leonardus installation
  • the integration of Leonardus as Jupyter kernel

To use it, pull the image hagenbund2/leojupyter
and start the JupyterLab X application using the command provided in the Docker hub repository's "Overview" section.

You should see:

JupyterLab Welcome

Follow the instructions to install a Python environment. And after selecting
"New session..." you will see the option to create a new notebook with
a LeoScript kernel.

Examples

To run one of the given LeoScript examples in the Docker image leonardus:

cd /usr/local/lib/leonardus/Examples && ./Hanoi.leo

You can use the calculator. For example:

lc 25346 95095 gcd
lc 1 2 1 33 { mul } for

To use the vocabulary Numbers and an arbitrary long rational number
for calculating 12^64:

lc -V Numbers 12 1 cvq 64 binexp

Jupyter notebooks

TODO: Jupyter notebooks -> USING

Build

See ARCHITECTURE.