Article View: net.lang.apl
Article #55Re: Indexing
From: utzoowatmathkdmoen
Date: Fri, 11 Feb 1983 04:05
Date: Fri, 11 Feb 1983 04:05
39 lines
1867 bytes
1867 bytes
Your indexing operations are a bit deceptive:
I1 .lh I2 .lh A equals A[ I1; I2 ]
but doesn't equal I1 .lh (I2 .lh A)
But yes, I agree. Indexing in APL is inconsistent with the rest
of the language. In particular, I feel that the action of replacing
part of an array value with something else should not be so closely
coupled to the assignment operation. So here are some alternatives:
Introducing @, the selection & replacement function.
@ array <-> array (ie, the identity operation)
replacement @ array <-> replacement
@[index] array <-> selects subelements from array
replacement @[index] array <-> creates a new array with the
subelements selected by index
replaced by replacement
Thus, A[index] <- replacement in the old notation
becomes A <- replacement @[index] A
Also, 0 @[3] .io 5 <-> 1 2 0 4 5
Note that indexing is now achieved by applying something similar to
an axis to the @ operator. In the old APL, indexing could be applied
to any array value, but indexing with replacement could only be applied
to a variable. This has been generalized, and the assignment statement
has been greatly simplified as a result.
The @ operator without an 'axis' doesn't look too useful, except perhaps
in 'expr2 @ expr1'. Perhaps it could be used with operators.
Another syntax, achieving roughly the same effect, is:
array [index] -- as in normal APL
array [index] replacement -- as above
Thus, A[index] <- replacement
becomes A <- A [index] replacement
Doug Moen, ...!watmath!kdmoen
Technical Details
Message-ID:
<bnews.watmath.4523>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
From: utzoo!watmath!kdmoen Newsgroups: net.lang.apl Title: Re: Indexing Article-I.D.: watmath.4523 Posted: Fri Feb 11 04:05:53 1983 Received: Fri Feb 11 07:24:34 1983 Subject: Re: Indexing Date: Fri, 11 Feb 1983 04:05:53 +0000 Message-ID: <bnews.watmath.4523>