This idea appeared in the forum. I haven't thought through the indexed
update, but were OpAssign a conjunction rather than an adverb...
OpAssign=: 1 :0
:
x~ =: x~ u y
)
A=: i.6
OpAssign=: 1 :0
:
(x) =: x~ u y
)
'A' +OpAssign 9
A
9 10 11 12 13 14
On 11/4/19 7:00 AM, programming-requ...@forums.jsoftware.com wrote:
Date: Sun, 3 Nov 2019 17:13:38 -0500
From: Jimmy Gauvin<jimmy.gau...@gmail.com>
To:programm...@jsoftware.com
Subject: [Jprogramming] Equivalent functionality to APL indexed
modified assignment
Message-ID:
<CAELWGOdmxcgtY81J_ZWK2zepVwqYMpDm6ehpELBppM5=qak...@mail.gmail.com>
Content-Type: text/plain; charset="UTF-8"
Hi,
some APLs have a combination of assignment with a function, for example :
a←⍳5
a+←1
a
2 3 4 5 6
This can be combined with index to good effect, for example counting
character occurrences in a text vector :
,bkt←0/⍨1+≢lc
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
bkt[lc⍳'short test']+←1
bkt,[.5]lc,' '
0 0 0 0 1 0 0 1 0 0 0 0 0 0 1 0 0 1 2 3 0 0 0 0 0 0 1
a b c d e f g h i j k l m n o p q r s t u v w x y z
Is there something equivalent in J ?
All I have come up with is the classical construct using the table operator
:
lc,:1": +/'short test'=/lc
abcdefghijklmnopqrstuvwxyz
00001001000000100123000000
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm