Bjoern Schliessmann <[EMAIL PROTECTED]> writes: > Alexander Schmolck wrote: > > > Apart from being less to type > > Cool. Less to type.
Yes. Readability is more important in many context, but for something designed for interactive experimentation and exploration little typing is absolutely essential. Would you use a calculator that would require Java-style boilerplate to add two numbers? I'd also venture that readability and typing ease are typically closely positively correlated (compare python to C++) and although I would not claim that J is particularly readable I'm also not an expert user (I doubt I would even then, but I'm sure it *does* make a difference). > > and it is superior in that it's > > generalizes much better, e.g: > > > > avg&.^. NB. geomtric mean > > avg&.% NB. harmonic mean > > avg M NB. column mean of matrix M > > avg"1 M NB. row mean of matrix M > > Is there any regularity in this? If it is, it's not obvious at all. Sure. ``f&.g`` is like ``(f o g) o g^-1`` in common mathemetical notation. ``^.`` is log and ``%`` is inversion/division. Making ``&.`` (it's called "under") available as a convenient abstraction is IMO one really useful innovation of J. As for the remaing two: it's similar to numpy in that one and the same function can normally operate on arrays of different dimensions (including scalars). In numpy you'd also write stuff like ``mean(M, axis=1)``, it's not exactly the same, although the axis abstraction comes from APL (another cool idea), J introduces a slightly different approach. The ``"1`` means "operate on cells of rank 1" (i.e. vectors), rather than "operate along a certain axis". For dyadic (2-argument) functions you can also specify different left and right rank, so you could write the outerproduct v'w thus: ``v *"0 1 w`` (multiply each 0-cell (i.e scalar) of v with each 1-cell (i.e. vector, there is only one) of w). Unlike the linear algebra notation this readily generalizes to more than 1 dimensional objects. BTW I don't think J is an ideal language, not even for numerical computing -- there are plenty of things I'd do differently and that includes measures that would IMO greatly aid readability (like getting rid of "ambivalence"[1]). But I have little doubt that, no matter what its flaws may be, APL (and J is really just an updated, ASCII-based APL) is one of the most innovative and important programming languages ever conceived. Anyone interested in the design of programming language for scientific computing ought to take a look at at least a look at it or one of its descendants. 'as Footnotes: [1] Basically almost every J function has a completely different meaning depending on whether you use it as a unary or binary function (just as conventionally "-" is abusively used for both substraction and negation). -- http://mail.python.org/mailman/listinfo/python-list