A straightforward solution would be:

   insert =: 1 : (':'; 'x (m&+ each { (<@:i.)"0 $x) } y')

   a =: 6 8$0
   b =: 4 3$1
   b 2 1 insert a
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 1 1 1 0 0 0 0
0 1 1 1 0 0 0 0
0 1 1 1 0 0 0 0
0 1 1 1 0 0 0 0

(but monadic { is maybe not straightforward)

Ben
________________________________________
From: [email protected] 
[[email protected]] on behalf of Sebastian 
[[email protected]]
Sent: Tuesday, October 21, 2014 16:04
To: [email protected]
Subject: [Jprogramming] Insert a 2 dimensional array to a n dimensional array

Hello,

I have a question similar to the question I had a few weeks before. The
question was how replace single values from a matrix
(http://jsoftware.com/pipermail/programming/2014-September/039225.html).
Now I would like to replace a matrix with at least 2 dimensions with
values from a 2 dimensional array.

The new values should replace the old values from the matrix, like this:

new data:
1 1 1
1 1 1
1 1 1

old data:
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0

result:

1 1 1 0
1 1 1 0
1 1 1 0
0 0 0 0

The insert position to the matrix should be parameterisable.

Best regards
Sebastian
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to