The "no base case" phrase might mean that there's some infinite loop transformation mechanism in the language.
That said, I also don't understand that result. Here's the example value 'ast' represented in J: t=:'.' ast=:t;(t;t);(t;(t;t);t);(t;(t;t;t);(t;t;t);t) And, here's the corresponding "depth vector in record format" mapped back onto the corresponding positions in ast: 0;(1;2);(1;(2;3);2);(1;(2;3;3);(2;3;3);2) So either this result is wrong, or 'depth' in this context does not have a simple relationship with 'depth' as we know it in J. Here's J's idea of the depths of each of the boxes: ;@(+L:0 L.)L:1^:_ L.L:0 ast 1 2 2 2 3 3 2 1 2 2 2 2 2 2 1 We could treat the top level box as depth 0 easily enough <: ;@(+L:0 L.)L:1^:_ L.L:0 ast 0 1 1 1 2 2 1 0 1 1 1 1 1 1 0 But obviously that's still different from that "depth vector in record format". Anyways... color me confused. Is there a simple way of describing the purpose of that "depth vector in record format"? Thanks, -- Raul On Sun, May 23, 2021 at 2:35 PM Raoul Schorer <raoul.scho...@gmail.com> wrote: > > Dear all, > > I am struggling with the translation of the following APL dyad to J: > > ∊ 0 {(⊢,(⍺+1)∇⊣)/⌽⍺,1↓⍵} y > > which is the expression to yield a depth vector from a tree in record > format (drawn from Dr. Hsu's thesis). Demo: > > t ← '∘' > ast ← t (t t) (t (t t) t) (t (t t t) (t t t) t) > ∊ 0 {(⊢,(⍺+1)∇⊣)/⌽⍺,1↓⍵} ast > 0 1 2 1 2 3 2 1 2 3 3 2 3 3 2 > > In particular, I don't understand the control flow and termination > condition for the recursion. Dr. Hsu says that this uses tree reduction > with no base case. > > An attempt at a partial litteral translation as: > > dv =. {{ (];(>:x) dv [)/\ |.x;}.y }} > > > results in an infinite loop. What am I missing? Is there some kind of > implicit termination condition in the ∇ primitive? > > > Thanks, > > Raoul > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm