in terms of copying one node to another, ((1 ; 0)&{:: <@[ each amendT 0 ]) 0 ;<(< i.5);i.4 ┌───────────┬─────────────────────┐ │┌─────────┐│┌───────────┬───────┐│ ││0 1 2 3 4│││┌─────────┐│0 1 2 3││ │└─────────┘│││0 1 2 3 4││ ││ │ ││└─────────┘│ ││ │ │└───────────┴───────┘│ └───────────┴─────────────────────┘
to delete the original node (move) {: each amendT 1 ((1 ; 0)&{:: <@[ each amendT 0 ]) (0 ;<(< i.5);i.4) ┌───────────┬─────────┐ │┌─────────┐│┌───────┐│ ││0 1 2 3 4│││0 1 2 3││ │└─────────┘│└───────┘│ └───────────┴─────────┘ When I said tree processing is ok, I was thinking more of user trees rather than "system trees" where the relationship among nodes is also user defined. I should also point out that it is only ok after definining my own functions to deal with trees. and I will repeat that I agree that }:: (with compatible indexing to {::) would be a big improvement, though the above uses a fairly simple workaround. ----- Original Message ----- From: Dan Bron <j...@bron.us> To: programm...@jsoftware.com Cc: Sent: Monday, September 8, 2014 2:30 PM Subject: Re: [Jprogramming] Ragged Array Shapes are Trees Raul wrote: > Note that J already supports trees. Devon wrote: > I have J code that uses trees which I run daily and > have been doing so for years. Pascal wrote: > I think trees are done at least ok, if not "right" already. Challenge: express, in J, the logic of rebalancing a heap (say, a Fibonacci heap, but I'm not particularly picky). For the sake of this exercise, you may ignore considerations of efficiency (though that's a bit of a self-contradiction, because heaps are frequently introduced specifically for the sake of efficiency). I am only interested in the directness, simplicity, elegance (lyricality) of the notation, in its current form, for expressing ideas about trees. We can make it efficient "later" (Pepe's TCO utility is a start). -Dan ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm