I myself was wondering about this dyadic hook (,~ >.) in the dyadic case when calculating the rank for the recursive call. I'm not sure why ceiling is necessary here or perhaps it is a typo and max was meant?
On Thu, Aug 29, 2013 at 4:55 PM, Jose Mario Quintana < [email protected]> wrote: > Henry (or any other enlighten person), > > I am aware that applyintree( > http://www.jsoftware.com/pipermail/general/2005-February/020612.html , > reproduced below) > can be used dyadically, for example, as follows > (see http://www.jsoftware.com/pipermail/programming/2007-March/005531.html > ): > > > unfetch=. [ applyintree > > 'qq' 1 unfetch 1;2;3 > ┌─┬──┬─┐ > │1│qq│3│ > └─┴──┴─┘ > > ('qq';1 2 3) (1;0) unfetch 1;(2;3);4 > ┌─┬──────────────┬─┐ > │1│┌──────────┬─┐│4│ > │ ││┌──┬─────┐│3││ │ > │ │││qq│1 2 3││ ││ │ > │ ││└──┴─────┘│ ││ │ > │ │└──────────┴─┘│ │ > └─┴──────────────┴─┘ > > 'qq' (1;0;2 1) unfetch 1;((<"0 i.3 4);3);4 > ┌─┬────────────────┬─┐ > │1│┌────────────┬─┐│4│ > │ ││┌─┬──┬──┬──┐│3││ │ > │ │││0│1 │2 │3 ││ ││ │ > │ ││├─┼──┼──┼──┤│ ││ │ > │ │││4│5 │6 │7 ││ ││ │ > │ ││├─┼──┼──┼──┤│ ││ │ > │ │││8│qq│10│11││ ││ │ > │ ││└─┴──┴──┴──┘│ ││ │ > │ │└────────────┴─┘│ │ > └─┴────────────────┴─┘ > > (1;0;2 1){:: 'qq' (1;0;2 1) unfetch 1;((<"0 i.3 4);3);4 > qq > > and even > > > (_1;(<_2;_3)) (1;0 ) unfetch 1;((<"0 i.3 4);3);4 > ┌─┬────────────────┬─┐ > │1│┌────────────┬─┐│4│ > │ ││┌──┬───────┐│3││ │ > │ │││_1│┌──┬──┐││ ││ │ > │ │││ ││_2│_3│││ ││ │ > │ │││ │└──┴──┘││ ││ │ > │ ││└──┴───────┘│ ││ │ > │ │└────────────┴─┘│ │ > └─┴────────────────┴─┘ > > but the commentary and the code suggest more general uses (apart from verbs > other than [) when the x-rank is greater than the y-rank but I cannot > figure it out. > > Am I right? If so, can you explain the dyadic form or give some examples. > > > > [Jprogramming] updating tree -- equivalent to what }:: would do*Henry > Rich* HenryHRich > at nc.rr.com > <programming% > 40jsoftware.com?Subject=%5BJprogramming%5D%20updating%20tree%20--%20equivalent%20to%20what%20%7D%3A%3A%20would%20do&In-Reply-To=20061028021404.51996.qmail%40web50312.mail.yahoo.com > > > *Sat Oct 28 10:21:33 HKT 2006* > > > - Previous message: [Jprogramming] updating tree -- equivalent to what > }:: would do > < > http://www.jsoftware.com/pipermail/programming/2006-October/003759.html> > - Next message: [Jprogramming] Neat coroutine implementation > < > http://www.jsoftware.com/pipermail/programming/2006-October/003762.html> > - *Messages sorted by:* [ date > ]< > http://www.jsoftware.com/pipermail/programming/2006-October/date.html#3761 > > > [ > thread ]< > http://www.jsoftware.com/pipermail/programming/2006-October/thread.html#3761 > > > [ > subject ]< > http://www.jsoftware.com/pipermail/programming/2006-October/subject.html#3761 > > > [ > author ]< > http://www.jsoftware.com/pipermail/programming/2006-October/author.html#3761 > > > > ------------------------------ > > Here's what I have (watch for long lines; there are only 2 > executable lines): > > NB. Conjunction. Apply u at the cell indicated by n > applyintree =: 2 : 0 > if. #n do. ((u applyintree (}.n)) L:_1 ({.n){y) ({.n)} y else. u y end. > :**NB. The rank is s,0 where s is the surplus of x-rank over y-rank. > This causes > NB. the cells of y to be matched up with the largest appropriate blocks x. > This > NB. is necessary because it is impossible to change the shape of the > values being modified > if. #n do. (x u applyintree (}.n) L:_ _1"(0 (,~ >.) x -&(#@$) a) (a =. > ({.n){y)) ({.n)} y > else. x u y end. > ) > > > Example use: > > fnx =. >: applyintree (0;2) x NB. Increment state > > [ applyintree n would replace. > > Henry Rich > > >* -----Original Message-----*>* From: programming-bounces at > jsoftware.com < > http://www.jsoftware.com/cgi-bin/mailman/listinfo/programming> *>* > [mailto:programming-bounces at jsoftware.com < > http://www.jsoftware.com/cgi-bin/mailman/listinfo/programming>] On Behalf > Of Pascal Jasmin*>* Sent: Friday, October 27, 2006 10:14 PM*>* To: > Programming forum*>* Subject: [Jprogramming] updating tree -- equivalent to > what *>* }:: would do*>* *>* Does anyone have code to update a tree? using > the {:: and < *>* S: 1 {:: index formats?*>* *>* for example:*>* > last10dig=: (/:~ @ (("."0":) @ (1000000000x &|)))*>* < S: 1 {:: ] > 5!:2 <'last10dig'*>* *>* Are there plans to implement }:: similarly to > }?*>* *>* *>* *>* > ----------------------------------------------------------------------*>* > For information about J forums see *>* > http://www.jsoftware.com/forums.htm* > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
