moving around the m term to be the "searched". There's probably a better
version that doesn't box.
ritem =: 1 : '(m -:"_ _1 ]) >@:({"0 1) (,&<~"_ _1)'
(2 4 $ 0) (16+i.2 4) ritem i. 3 2 4
----- Original Message -----
From: Kip Murray <[email protected]>
To: "[email protected]" <[email protected]>
Sent: Wednesday, March 9, 2016 5:26 PM
Subject: [Jprogramming] Replace Items
Adverb ritem creates a verb which replaces by x items in array m that
match y
Below are examples. How would you write the adverb? --Kip Murray
C
0 1 2 3
4 5 6 7
0 1 2 3
0 0 0 0 C ritem 0 1 2 3
0 0 0 0
4 5 6 7
0 0 0 0
A
0 1 2 3
4 5 6 7
8 9 10 11
12 13 14 15
16 17 18 19
20 21 22 23
(2 4 $ 0) A ritem 16+i.2 4
0 1 2 3
4 5 6 7
8 9 10 11
12 13 14 15
0 0 0 0
0 0 0 0
--
Sent from Gmail Mobile
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm