[PYTHON MATRIX-SIG] J-style arrays in Python

Hinsen Konrad hinsenk@ere.umontreal.ca
Tue, 26 Sep 1995 21:38:49 -0400

To bring back some life into this discussion group, I'll distribute a
Python implementation of J-like arrays, to give those unfamiliar with
J a chance to become familiar with its array and rank system. And of
course it is also usable, as long as the arrays don't become too big.
This is a first test version; many important functions are still
missing, others (like output formatting) need substantial improvement,
and many could probably be made faster with some thought.

To make (my) life simpler, I tried to stick to J's conventions as much
as possible (but hopefully without violating Python traditions). I am
not claiming that this is semantically the best way to implement arrays,
but it is a start.

Some general remarks:

- Since my implementation uses nested lists to represent arrays,
  the elements can be arbitrary objects.

- Like arrays in J, my arrays are immutable, i.e. there is no
  provision for changing individual elements. The reason for
  making arrays immutable in J was that J is half-way to being
  a functional language (it is not a pure functional language,
  but many substantial problems can easily be solved in a
  functional way). I have never missed element assignment, but
  probably there are some good applications...

- All functions are implemented as external functions, not as
  methods. The main reason is that at first I could not think of
  a way to implement methods with variable rank, although later
  I figured out how to do this (in the same way as I implemented

I'll send two Python files; the first is the Array module itself,
and the second a kind of simple tutorial. Let me know if
anything is unclear. And let me know what you think of the
whole implementation!

Konrad Hinsen                     | E-Mail: hinsenk@ere.umontreal.ca
Departement de chimie             | Tel.: +1-514-343-6111 ext. 3953
Universite de Montreal            | Fax:  +1-514-343-7586
C.P. 6128, succ. A                | Deutsch/Esperanto/English/Nederlands/
Montreal (QC) H3C 3J7             | Francais (phase experimentale)

MATRIX-SIG  - SIG on Matrix Math for Python

send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org