[email protected] wrote: > For your original format, with a transition matrix to simplify finding > "catenaries" for each column: > > tm=:3 4 $ 0 1 0 1 2 2 2 2 3 1 3 1 > start=: 0,~ = + 2*(=>:) NB. same height = 1, direct children = 2, others > = 0 > step=: {::&tm@, NB. apply tm > nub=: ] ,:~ 4* 2= ] NB. '-' before 'o' > pt=: [: }:@|:@}. [: ,/ [ (' |o+-' {~ [: nub [: step/\. start)"_ 0 ~. > pt 0 1 2 2 1 1 2 3 2 3 3 2 3 3 > > As a long-liner: > > pt=:[: }:@|:@}. [: ,/ [ (' |o+-' {~ [: (,:~ 4* 2= ])~ [: {::&(3 4 $ 0 1 0 > 1 2 2 2 2 3 1 3 1)@,/\. 0,~ = + 2*(=>:))"_ 0 ~.
This catenary finder is straight-up inspired. It's exactly the kind of array-thinking I was groping around for. Thank you for the ideas! ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
