Following in the footsteps of libpython-clj and libjulia-clj, libapl-clj provides native interop from Clojure into GNU APL.
Pre-alpha: APL shared library is able to be loaded on Linux.
- Arbitrary APL strings can be run, and the values can be extracted into strings.
- APL<->Clojure data copy is accomplished easily
- Zero-copy paradigm supported
- There are system instabilities, your REPL may crash from time to time.
- automatic GC not yet implemented
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.
Tested on Linux Mint 19. Should also work on MacOS and probably Windows if you know how to set environment variables (see below).
- Follow the directions to download GNU APL.
- When installing APL, use the following options:
make develop_lib
sudo make install
- The default shared library installation path is
/usr/local/lib/apl
. The filename islibapl.so
. Iflibapl.so
is installed somewhere else, please set yourAPL_LIBRARY_PATH
environment variable to the correct path before runninginitialize!
.
(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]
- Push to Clojars
- Marshall pointers to native Clojure datatypes
- Zero-copy pathway between APL and Clojure for monster performance
- Ergonomic Clojure API
- Documentation
- Tests
- User-defined APL functions
- APL function combinators
- Garbage Collection
- Remove reflection