That's awesome, and thank you. For posterity's sake, here's the string-eval 
version I cooked up while refusing to give in to recursion:


t =: 1 2 3 ; <4 ; < 5 6; <7 8
n =: 123
addr =: 1 1 0

gener =: [:<')',[:,&'<t' '}'1}[:;[:,&'{>'&.>[:":&.>[:;/|.
". (;($addr)#<'(<') , 'n', ;|.gener\ addr


My hack: build up the nested, shelled } constructs, use some ugly >< that would 
make anyone cry, and then eval it all. Hope it's helpful to someone else down 
the road.


-----Original Message-----
From: Programming [mailto:[email protected]] On Behalf 
Of Henry Rich
Sent: Wednesday, March 14, 2018 11:31 PM
To: [email protected]
Subject: Re: [Jprogramming] Question about updating boxed tree content

Yes, }:: is reserved for Emend which will do what you want. Someday. Maybe 
erelong.

In the meantime, use applyintree from
http://code.jsoftware.com/wiki/Vocabulary/AmendingBoxedStructures

    a =: 1 2 3 ; <4 ; < 5 6; <7 8
    a
+-----+-------------+
|1 2 3|+-+---------+|
|     ||4|+---+---+||
|     || ||5 6|7 8|||
|     || |+---+---+||
|     |+-+---------+|
+-----+-------------+
   (<123) [ applyintree (1;1;0) a
+-----+---------------+
|1 2 3|+-+-----------+|
|     ||4|+-----+---+||
|     || ||+---+|7 8|||
|     || |||123||   |||
|     || ||+---+|   |||
|     || |+-----+---+||
|     |+-+-----------+|
+-----+---------------+


Henry Rich

On 3/14/2018 10:54 PM, [email protected] wrote:
> There's a question I'm tracking on Stack Overflow that I'm trying to solve:
>
> https://stackoverflow.com/questions/49288689/how-to-amend-data-in-a-bo
> x-j-pr
> ogramming
>
>   
>
> Given a multi-level box:
>
> a =: 1 2 3 ; <4 ; < 5 6; <7 8
>
>   
>
> How to you amend something given an address multiple levels into the 
> box, e.g. the <5 6 part? I've tried some combination of S: and {:: and 
> } however I can't seem to crack it. I might have expected this to work:
>
>   
>
> (<123) (1;1;0)} a
>
>   
>
> However, in this example, the (1;1;0) replaces item 1 and 0, treating 
> the
> 1;1;0 as the list of elements to amend, as opposed to the array index 
> to be amended, as is the case with (1;1;0) {:: a
>
>   
>
> Does this mean that J needs a new amend operator, something akin to:
>
>   
>
> (<123) (1;1;0) }:: a
>
>   
>
> ?
>
>   
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm


---
This email has been checked for viruses by AVG.
http://www.avg.com

----------------------------------------------------------------------
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