Oops, I should have posted:
byLevel=: 3 :0
'w A maxLevel'=. y
mask=. -. +./\ =i.{:$w
reflect=. 0&< * ] -"1"1 2 A *"2 1 ]
keep=. (0 < ^&mask"2) >&(*./"1) =&0
weights=. currentLevel=.,:w
for.i.maxLevel do.
currentLevel=. (keep #&(,/) ]) reflect currentLevel
weights=. weights, currentLevel
end.
)
(This change only matters, functionally, for the case when
maxLevel is 0, though it could be argued that this version's
style is better.)
--
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm