Setting one leaf in a tree means re-creating the tree, for boxed trees.

So you could do something like this:

treeset=:1 :0
:
  if. 1>:#m do.
    (<x) (0 {:: m)} y
  else.
    (<x (}.m) treeset ({.m){::y) ({.m)} y
  end.
)

   T=: 'the cat' ; 'sat' ; < 'on' ; < ('the';'mat')
   'hat' (2;1;1) treeset T

Thanks,

-- 
Raul



On Thu, Nov 13, 2014 at 1:28 PM, Sergey Kamenev <[email protected]> wrote:
> I reading http://www.jsoftware.com/help/learning/32.htm
>
> This chapter about boxed trees.
>
> J have beatiful verb Fetch {::
>
> This verb get any leaf by path.
>
> I need verb for setting any selected leaf by path.
>
> NB. Tree
> ] T =:  'the cat' ; 'sat' ; < 'on' ; < ('the';'mat')
>
> ND. Get leaf by path
> (2; 1; 1) {:: T
> mat
>
> How to change only one leaf in tree e.g. from "mat" to "xyz" without
> re-creating the tree?
>
> Thank you!
> Sergey
> ----------------------------------------------------------------------
> 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