An open API service indexing awesome lists of open source software.

https://github.com/answerdotai/aplnb

An IPython magic for Dyalog APL
https://github.com/answerdotai/aplnb

Last synced: 5 months ago
JSON representation

An IPython magic for Dyalog APL

Awesome Lists containing this project

README

        

# Using `apl` magics

`aplnb` adds `%apl` and `%%apl` functions to Jupyter and IPython, which
exectute expressions in Dyalog APL.

## Installation

First, install [Dyalog APL](https://www.dyalog.com/). Dyalog provides a
basic license for free. Once Dyalog is installed, install aplnb with:

pip install aplnb

Once that’s complete, you can install the magics to all IPython and
Jupyter sessions automatically by running in your terminal:

aplnb_install

## Usage

After first running an `apl` magic in a notebook, the [APL language
bar](https://abrudz.github.io/lb/apl) by Adám Brudzewsky is
automatically added to the current page. (There is one change to Adám’s
original version, which is that you can type a backtick twice in a row
to enter triple backticks. To get a `⋄` glyph, type backtick-q.)

You can use either a cell magic (`%%ai`) or a line magic (`%ai`). In
either case the expression is evaluated and returned:

``` python
%%apl
y←⍳3
z←y×y
```

[1, 4, 9]

``` python
%apl 3×⍳4
```

[3, 6, 9, 12]

``` python
%apl ⎕A
```

'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

You can store the value of an expression in a python variable using the
line magic. Scalars, lists, and nest lists are used:

``` python
z = %apl z
print(z)
```

[1, 4, 9]

To avoid having the expression returned and/or displayed, end the last
line with a `;`.

``` python
%%apl
a←2 2 ⍴ ⍳4;
```

You can print from cell magics using the standard APL ⎕ glyph:

``` python
%%apl
⎕←a;
```

1 2
3 4

To use numpy, just pass the result of `%apl` into `np.array`:

``` python
import numpy as np
```

``` python
a = %apl a
np.array(a)
```

array([[1, 2],
[3, 4]])

## Learning APL

To start learning APL, follow the [17 video
series](https://forums.fast.ai/t/apl-array-programming/97188) run by
Jeremy Howard, and have a look at the [study
notes](https://fastai.github.io/apl-study/apl.html).