I think you mean "tree representation" where you wrote "linear representation".
Linear representation would often mean a representation which fits on a line. Thanks, -- Raul On Fri, Feb 13, 2015 at 9:37 AM, Brian Schott <[email protected]> wrote: > Linda, > > Your question "Is there a general preference among programmers for count3 > or count4" lead me to some experimentation, but I don't think I can answer > your question directly. My preference is for the a composition of smaller > parts, which led to the following sequence which produced, especially in > your preferred linear representation to a surprising result where the > beginning is "-- @ -". I have never noticed such a beginning of a linear > representation, but lr is not my favorite representation, so I rarely use > it. > > countB =: <@cb"1@pairs > countBf =: <@cb"1@pairs f. > 9!:3 ]5 4 > > countB > <@cb"1@pairs > ┌─ < > ┌─ @ ─┴─ cb > ┌─ " ───┴─ 1 > ── @ ─┴─ pairs > countBf > <@([: <"0 >:@i.)"1@(([: >:@i. [) ,"0/ [: >:@i. ]) > ┌─ < > │ ┌─ [: > ┌─ @ ─┤ │ ┌─ < > │ │ ├─ " ─┴─ 0 > │ └─────┤ > ┌─ " ─┤ │ ┌─ >: > │ │ └─ @ ─┴─ i. > │ └─ 1 > │ ┌─ [: > │ │ ┌─ >: > ── @ ─┤ ┌─────┼─ @ ─┴─ i. > │ │ └─ [ > │ │ ┌─ , > │ ├─ / ─── " ─┴─ 0 > └─────┤ > │ ┌─ [: > │ │ ┌─ >: > └─────┼─ @ ─┴─ i. > └─ ] > 2 (countB -: count) 2 > 1 > > > On Fri, Feb 13, 2015 at 4:25 AM, Linda Alvord <[email protected]> > wrote: > >> Pascal, Your suggestions helped me understand this problem: >> >> >> >> pairs=: 13 :'(>:@i. x),"0/>:@i. y' >> >> cb=: 13 :'<"0 >:@i. y' >> >> cb >> >> [: <"0 >:@i. >> >> count=: 13 :'(<@cb)"1 x pairs y' >> >> 2 count 2 >> >> ┌───┬─────┐ >> │┌─┐│┌─┬─┐│ >> ││1│││1│2││ >> │└─┘│└─┴─┘│ >> ├───┼─────┤ >> │┌─┐│┌─┬─┐│ >> ││1│││1│2││ >> │├─┤│├─┼─┤│ >> ││2│││3│4││ >> │└─┘│└─┴─┘│ >> └───┴─────┘ >> >> -- > (B=) > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
