Hi Harvey,
Pascal got you most of the way there, but I will add the idea of using a
selector to the Amend adverb to provide more precision.
[ t=: <"0 i. 2 3 4 NB. creates rank three boxed brick
┌──┬──┬──┬──┐
│0 │1 │2 │3 │
├──┼──┼──┼──┤
│4 │5 │6 │7 │
├──┼──┼──┼──┤
│8 │9 │10│11│
└──┴──┴──┴──┘
┌──┬──┬──┬──┐
│12│13│14│15│
├──┼──┼──┼──┤
│16│17│18│19│
├──┼──┼──┼──┤
│20│21│22│23│
└──┴──┴──┴──┘
[ rep=: <'a' NB. replacement value for selected addresses
┌─┐
│a│
└─┘
rep (1 }) t NB. replaces all of the 1 item with rep's
┌─┬─┬──┬──┐
│0│1│2 │3 │
├─┼─┼──┼──┤
│4│5│6 │7 │
├─┼─┼──┼──┤
│8│9│10│11│
└─┴─┴──┴──┘
┌─┬─┬──┬──┐
│a│a│a │a │
├─┼─┼──┼──┤
│a│a│a │a │
├─┼─┼──┼──┤
│a│a│a │a │
└─┴─┴──┴──┘
rep ((<1 0) }) t NB. replaces 0th row of the 1 item with rep's. (< 1 0) is
necessary for selector rules
┌──┬──┬──┬──┐
│0 │1 │2 │3 │
├──┼──┼──┼──┤
│4 │5 │6 │7 │
├──┼──┼──┼──┤
│8 │9 │10│11│
└──┴──┴──┴──┘
┌──┬──┬──┬──┐
│a │a │a │a │
├──┼──┼──┼──┤
│16│17│18│19│
├──┼──┼──┼──┤
│20│21│22│23│
└──┴──┴──┴──┘
rep ((<1 0 2) }) t NB. replaces a single box in the 0th row of the 1 item
with rep. (< 1 0 2) is necessary for selector rules
┌──┬──┬──┬──┐
│0 │1 │2 │3 │
├──┼──┼──┼──┤
│4 │5 │6 │7 │
├──┼──┼──┼──┤
│8 │9 │10│11│
└──┴──┴──┴──┘
┌──┬──┬──┬──┐
│12│13│a │15│
├──┼──┼──┼──┤
│16│17│18│19│
├──┼──┼──┼──┤
│20│21│22│23│
└──┴──┴──┴──┘
Hope this helps.
Cheers, bob
> On Aug 6, 2020, at 21:01, HH PackRat <[email protected]> wrote:
>
> On 8/6/20, 'Pascal Jasmin' via Programming <[email protected]> wrote:
>>> NB. (row{data)=. (< interpolated) start } row{data
>>
>> to change row 1,
>> 2 2 2 2 2 (1}) i. 4 5
>> 0 1 2 3 4
>> 2 2 2 2 2
>> 10 11 12 13 14
>> 15 16 17 18 19
>>
>> if your data is boxed by column,
>> 2 3 2 3 2 (1}) each <"1&.|: i. 4 5 NB. the new row can be a "boxed record"
>
> Thanks for your response, but your examples are the same kind of thing
> I was encountering in the few sources that addressed amending. It did
> not address the issue of "drilling down" into the middle of a table
> and changing a value.
>
> There are 3 levels of data: table (called "data"), row, and column.
> Thus, every box of the table has a 3-part address. Your example does
> not indicate how to change a single cell in a table. The diagram
> below (sorry, I can only do a proportional font) shows the beginning
> of the transposed data:
>
> ┌───────┬───────┬──────┬─┬──────┬───────┬─
> │261.78 │263.33 │263.27 │0│263.23 │264.22 │
> ├───────┼───────┼──────┼─┼──────┼───────┼─
> │264.02 │264.59 │263.47 │0 │264.87 │265.17 │
> ├───────┼───────┼──────┼─┼──────┼───────┼─
> │261.54 │262.54 │262.84 │0 │262.62 │262.82 │
> ├───────┼───────┼──────┼─┼──────┼───────┼─
> │263.33 │263.27 │263.23 │0 │264.22 │263.92 │
> ├───────┼───────┼──────┼─┼──────┼───────┼─
> │1360000 │1150000 │300000 │0 │940000 │1040000 │
> └───────┴───────┴──────┴─┴──────┴───────┴─
>
> How would you amend (in place) the entire data (table) so that the box
> at column 3, row 2, would have the literal value '262.73' instead of
> zero? This is the essence of what I was trying to ask.
>
> Harvey
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm