Skip to main content

Mini APL in Python Language Experiment. Uses numpy arrays.

Project description

MARPLE

MARPLE is an experimental APL interpreter that runs on Linux and the Pico 2 microcontroler. It already has enough features to be usable, though may more are planned.

It was inspired by Rodrigo Girão Serrão's RGSPL and Iverson's Dictionary of APL. It has taken some additional features from Dyalog APL(TM).

Marple is written in Python! It has acceptable performance due to the use of numpy on Linux and ulab.numpy on the Pico 2.

I designed the interpreter and directed its development, but all the code, all the tests and almost all of the documentation have been generated by Claude code. So far the development has taken 8 days.

While MARPLE has extensive automated tests, it is not and will never be a commercial strength APL. If that's what you want, get Dyalog APL. Dyalog APL is free for non-commercial work

See the full feature list, architecture, and documentation.

Platform support

MARPLE is developed and tested on Linux and the Raspberry Pi Pico 2 (Pimoroni Presto). It does not currently run on Windows or Mac.

Quick start

Install uv if you don't have it, then:

git clone https://github.com/romilly/marple.git
cd marple
uv venv
source venv/bin/activate
uv pip install -r requirements.txt
marple
MARPLE v0.6.17 - Mini APL in Python
CLEAR WS

      ⍳5
1 2 3 4 5
      +/⍳100
5050
      fact←{⍺←1 ⋄ ⍵=0:⍺ ⋄ (⍺×⍵)∇ ⍵-1}
      fact 20
2432902008176640000

PRIDE Web IDE

From within the virtual environment:

python -m marple.web.server

Open http://localhost:8888/ in your browser.

PRIDE features

  • a clickable language bar for APL glyph input
  • workspace panel,
  • session with system commands,
  • session save/load, and
  • interactive ⎕/⍞ input.

Jupyter Notebook

uv pip install marple-lang[jupyter]
marple-jupyter-install
jupyter notebook

Select MARPLE (APL) as the kernel.

Running scripts

marple examples/01_primitives.marple

Pico deployment

MARPLE can be deployed to a Pimoroni Presto (Raspberry Pi Pico 2 with 480x480 touchscreen LCD). The REPL session mirrors to the LCD with a custom APL bitmap font. Other Pico boards are not currently supported.

./scripts/deploy.sh                                        # deploy to connected Presto
python scripts/pico_client.py                              # interactive REPL
python scripts/pico_client.py --script examples/12_life.marple  # run a script

To evaluate APL on a connected Presto from the PRIDE web IDE:

python -m marple.web.server --pico-port /dev/ttyACM0

See the demo videos, a demo of Bob Smith's partition functions, )load part_fns, and Conway's Game of Life example.

APL character input

Dyalog keyboard layout (recommended)

On Linux with an extended keyboard (with a Windows/Super key), run:

./scripts/aplkeys.sh

This configures the Dyalog APL keyboard layout using setxkbmap. Hold the Windows key (Super) to type APL glyphs; hold Shift+Windows for the extended set. Each key has up to four meanings:

┌────────┐
│~ ⌺     │  top-left: Shifted        top-right: Shift+Win
│` ⋄     │  bottom-left: Unshifted   bottom-right: Win
└────────┘

Full US layout (see Dyalog keyboard reference for other layouts):

┌────┬────┬────┬────┬────┬────┬────┬────┬────┬────┬────┬────┬────┬─────────┐
│~ ⌺ │! ⌶ │@ ⍫ │# ⍒ │$ ⍋ │% ⌽ │^ ⍉ │& ⊖ │* ⍟ │( ⍱ │) ⍲ │_ ! │+ ⌹ │Backspace│
│` ⋄ │1 ¨ │2 ¯ │3 < │4 ≤ │5 = │6 ≥ │7 > │8 ≠ │9 ∨ │0 ∧ │- × │= ÷ │         │
├────┴──┬─┴──┬─┴──┬─┴──┬─┴──┬─┴──┬─┴──┬─┴──┬─┴──┬─┴──┬─┴──┬─┴──┬─┴──┬──────┤
│Tab    │Q   │W   │E ⍷ │R   │T ⍨ │Y   │U   │I ⍸ │O ⍥ │P ⍣ │{ ⍞ │} ⍬ │| ⊣   │
│       │q ? │w ⍵ │e ∊ │r ⍴ │t ~ │y ↑ │u ↓ │i ⍳ │o ○ │p * │[ ← │] → │\ ⊢   │
├───────┴┬───┴┬───┴┬───┴┬───┴┬───┴┬───┴┬───┴┬───┴┬───┴┬───┴┬───┴┬───┴──────┤
│Caps    │A   │S   │D   │F ⍛ │G   │H   │J ⍤ │K ⌸ │L ⌷ │: ≡ │" ≢ │Enter     │
│Lock    │a ⍺ │s ⌈ │d ⌊ │f _ │g ∇ │h ∆ │j ∘ │k ' │l ⎕ │; ⍎ │' ⍕ │          │
├────────┴──┬─┴──┬─┴──┬─┴──┬─┴──┬─┴──┬─┴──┬─┴──┬─┴──┬─┴──┬─┴──┬─┴──────────┤
│Shift      │Z ⊆ │X   │C   │V   │B   │N   │M   │< ⍪ │> ⍙ │? ⍠ │Shift       │
│           │z ⊂ │x ⊃ │c ∩ │v ∪ │b ⊥ │n ⊤ │m | │, ⍝ │. ⍀ │/ ⌿ │            │
├───────┬─────┬──────┬──────────────────────────┬──────┬──────┬─────┬──────┤
│Ctrl   │Win  │Alt   │        Space bar         │Alt Gr│Win   │Menu │Ctrl  │
└───────┴─────┴──────┴──────────────────────────┴──────┴──────┴─────┴──────┘

PRIDE language bar

In the PRIDE web IDE, you can click glyphs in the language bar at the top of the screen. No keyboard setup required.

System commands

Command Action
)off Exit
)clear Clear workspace
)wsid [name] Show or set workspace ID
)save [name] Save workspace
)load name Load workspace
)lib List saved workspaces
)drop name Delete a saved workspace
)fns [ns] List defined functions
)ops [ns] List defined operators
)vars List defined variables

Development

uv pip install -r requirements-test.txt
pytest                # fast tests (~1.2s)
pytest -m slow        # PRIDE, WebSocket, deep TCO, ⎕DL tests
pyright src/

References

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

marple_lang-0.7.1.tar.gz (83.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

marple_lang-0.7.1-py2.py3-none-any.whl (92.5 kB view details)

Uploaded Python 2Python 3

File details

Details for the file marple_lang-0.7.1.tar.gz.

File metadata

  • Download URL: marple_lang-0.7.1.tar.gz
  • Upload date:
  • Size: 83.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for marple_lang-0.7.1.tar.gz
Algorithm Hash digest
SHA256 b70e1e813d71efe3e704a57106307a670df35b950145f2759d3b1ade2e2c7b45
MD5 1720016ecf06a3bac939da90be8788be
BLAKE2b-256 5fa6c745c1eaafd4313d9fffe46381d86dd198f15da8949006c138ed12e2fd05

See more details on using hashes here.

File details

Details for the file marple_lang-0.7.1-py2.py3-none-any.whl.

File metadata

  • Download URL: marple_lang-0.7.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 92.5 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for marple_lang-0.7.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 9ffaff7ec83c7056d40dd6f4379cc8428c2182419c519dc4e1d60d5a4d100299
MD5 1332eea2c91e82db737cbcefbd1c3e7e
BLAKE2b-256 71c733cd7017fccbd6cd29b51e4d9c767ebce209666c188ff02df6def23c8286

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page