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