Giter Site home page Giter Site logo

arrpl's Introduction

arrpl

Array processing library for Python inspired by APL

Basically you can work in Python and use APL-like monadic and diadic functions and operators to work on pythons lists. Like this:

A = [[1,2],[3,4]]
B = [7,8]
C = [2,1]

assert B -PLUS- 1 == [7, 8]
assert B -PLUS- C == [9, 9]

Python doesn't have operator overloading except for a predefined set, so in order to implement new words, I had to borrow an idea from Ferdinand Jamitzky. You shoud better check the code, it is better than any possible explanation. Long story short, functions (as in APL) ought to be surrounded by '-' signs, and operators (as in APL) - to be bounded with functions by '+' sign:

assert -PLUS+REDUCE- B == 15            # +/ B
assert (B -PLUS+INNER+MUL- C) == 22     # B +.× C 
assert (A -PLUS+INNER+MUL- A) == [[7, 10],[15,22]]  # A +.× A

The order of execution is left to right, as in Python, not like in APL:

assert ((-MINUS- 1) -PLUS- 2 -MUL- 3 -PLUS- [1, 2, 3]) == [4, 5, 6]

Generally, as you might wittness, it is not APL. It is Python with the some new syntax sweets.

So far I have implemented several functions:

PLUS
MINUS
MUL
DIV
MOD
POW

RANK      # ⍴
INDEX     # ⍳
MIRROR    # ⌽
WIRROR    # ⊖
TRANSPOSE # ⍉


NOT
AND
OR
LT
LE
EQ
GT
GE
NE
SELECT

And a few operators:

MAP
REDUCE
INNER
OUTER

Have fun!

arrpl's People

Contributors

akalenuk avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.