Home

Awesome

Clojars Project

libapl-clj being awesome

libapl-clj

Following in the footsteps of libpython-clj and libjulia-clj, libapl-clj provides native interop from Clojure into GNU APL.

Status

Pre-alpha: APL shared library is able to be loaded on Linux.

Overview

APL is a fantastic tensor processing language with a ton of power. It's work has been hugely inspirational to libraries like Python's numpy and dtype-next.

The aim of this library is to provide native interop for APL from Clojure.

Usage

Tested on Linux Mint 19. Should also work on MacOS and probably Windows if you know how to set environment variables (see below).

  1. Follow the directions to download GNU APL.
  2. When installing APL, use the following options:
make develop_lib
sudo make install
  1. The default shared library installation path is /usr/local/lib/apl. The filename is libapl.so. If libapl.so is installed somewhere else, please set your APL_LIBRARY_PATH environment variable to the correct path before running initialize!.

Example

(require '[libapl-clj.apl :as apl])

apl/+
;;=> #function[libapl-clj.prototype/jvm-fn/fn--23227]
(apl/+ 1 2)
;;=> 3
(apl/+ [1 2 3] [4 5 6])
;;=>
#tech.v3.tensor<object>[3]
[5 7 9]

(apl/display! (apl/+ [1 2 3] [4 5 6]))

┏→━━━━┓
┃5 7 9┃
┗━━━━━┛

(apl/× [1 2 3] [4 5 6])
;;=> #tech.v3.tensor<object>[3]
[4 10 18]

(apl/⍴ [2 3 5] (first "a"))
;;=>
#tech.v3.tensor<object>[2 3 5]
[[[a a a a a]
  [a a a a a]
  [a a a a a]]
 [[a a a a a]
  [a a a a a]
  [a a a a a]]]

(apl/display! (apl/⍴ [2 3 5] (first "a")))
;;=>
┏→━━━━┓
↓aaaaa┃
┃aaaaa┃
┃aaaaa┃
┃     ┃
┃aaaaa┃
┃aaaaa┃
┃aaaaa┃
┗━━━━━┛

(apl/reduce apl/⌈ [[1 2 3] [3 5 6] [1 2 3]])
#tech.v3.tensor<object>[3]
[3 6 3]

(apl/reduce apl/⌈ 1 [[1 2 3] [3 5 6] [1 2 3]])
#tech.v3.tensor<object>[3]
[3 6 3]

Roadmap

Alpha-release

Beta-release

1.0 Release