Adding to Raul's solution, it can be simplified a little by removing the excess
]'s
pad =: (1&$:) : ((0,.~0,.0,~0,]) ^:[ )
pad i. 3 4
0 0 0 0 0 0
0 0 1 2 3 0
0 4 5 6 7 0
0 8 9 10 11 0
0 0 0 0 0 0
> On May 3, 2019, at 9:37 AM, Raul Miller <[email protected]> wrote:
>
> pad =: (1&$:@]) : ((0,.~0,.0,~0,]) ^:[ ])
>
> Thanks,
>
> --
> Raul
>
> On Fri, May 3, 2019 at 12:35 PM Brian Schott <[email protected]> wrote:
>>
>> How do I create the verb `pad` below so that the first and the last
>> expressions below produce the same result?
>>
>> pad =: (1&$:@]) : (0,.~0,.0,~0,]) ^:[ ]
>> $ 1 pad i. 3 4
>> 5 6
>> $ 2 pad i. 3 4
>> 7 8
>> $ pad i. 3 4
>> 3 4 25 26
>>
>>
>> --
>> (B=)
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm