there is no }::

This conjunction seems to enable a solution for most similar problems.  It is 
set to take verbs only, and you get to learn a lot about conjunctions and each 
by practising with it. :P

amend_z_ =: 2 : 0  NB. v is n or n{"num 
s=. v"_ y 
(u (s{y)) (s}) y 
: 
s=. v"_ y 
(x u (s{y)) (s}) y 
)

 'xyz'"_ each amend 1 each amend 1 each  amend 2   'the cat' ; 'sat' ; < 'on' ; 
< ('the';'mat')

A more tacit variation, that seems to always work so far:

   hook =: 2 : '([: u v) : (u v) ' 
   amendT =: 2 : ' u hook (n { ]) n} ]'

  'xyz'"_ each amendT 1 each amendT 1 each  amendT 2   'the cat' ; 'sat' ; < 
'on' ; < ('the';'mat')

This could be expanded as the reverse (|.) of the {:: notation


----- Original Message -----
From: Sergey Kamenev <[email protected]>
To: [email protected]
Cc: 
Sent: Thursday, November 13, 2014 1:28 PM
Subject: [Jprogramming] Setting arbitrary leaf of tree

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