My tree code can be found here: https://github.com/DevonMcC/trees .

On Mon, Jul 20, 2020 at 4:20 PM Devon McCormick <[email protected]> wrote:

> I meant the J essay suggested by Jan-Pieter was the one I used.
>
> On Mon, Jul 20, 2020 at 4:00 PM Devon McCormick <[email protected]>
> wrote:
>
>> It was simple to convert my parent-index form to use with the tree
>> display function "tree":
>>    nmsb=.
>> 'C:';'n0';'n1';'n00';'n01';'n10';'n11';'n12';'n100';'n110';'n111';'n112'
>> NB. Node names
>>    trb=. _1 0 0 1 1 2 2 2 5 6 6 6 NB. Parent-index tree
>>    EW=: {: BOXC=: 11{.16}.a.      NB. Line-drawing characters
>>    tree (}.trb{nmsb),.}.nmsb
>> +----------------------------+
>> |             ┌─ n00         |
>> |      ┌─ n0 ─┴─ n01         |
>> |      │      ┌─ n10 ─── n100|
>> |─ C: ─┤      │       ┌─ n110|
>> |      └─ n1 ─┼─ n11 ─┼─ n111|
>> |             │       └─ n112|
>> |             └─ n12         |
>> +----------------------------+
>>
>>
>> On Mon, Jul 20, 2020 at 3:54 PM Devon McCormick <[email protected]>
>> wrote:
>>
>>> Thanks everyone for the responses.  I have watched the APL video
>>> recently but have not tried to convert Aaron's code to J.  However, the
>>> essay suggested by Julian does what I want.
>>> Bo's response is intriguing but I have not figured out how to convert my
>>> tree representation to ordinal numbers.
>>>
>>> On Mon, Jul 20, 2020 at 1:40 PM 'Bo Jacoby' via Programming <
>>> [email protected]> wrote:
>>>
>>>>  Minor simplification:
>>>>
>>>>       n=.(/:{])12 3$'000100200110120210220230211221222223'
>>>>
>>>>       (6-~+/"1 n='0')|."0 1 n,"1'00',(4#' '),'§'
>>>>
>>>>
>>>>
>>>> Thanks.
>>>> Bo.
>>>>     Den søndag den 19. juli 2020 23.49.17 CEST skrev 'Bo Jacoby' via
>>>> Programming <[email protected]>:
>>>>
>>>>   I use ordinal fractions.
>>>>
>>>>
>>>>
>>>> nms=.'000';'100';'200';'110';'120';'210';'220';'230';'211';'221';'222';'223'
>>>>
>>>>
>>>>
>>>> The digits are ordinal numbers, 1, 2, 3, . . . rather than cardinal
>>>> numbers 0, 1, 2, . . .
>>>> The digit zero means everything rather than nothing.
>>>>
>>>>
>>>>  
>>>> nms=.'000','100','200','110','120','210','220','230','211','221','222',:'223'
>>>>
>>>>    nms=.(/:nms){nms NB. sort
>>>>
>>>>    (3-~+/"1 nms='0')|."0 1 nms,"1'   '
>>>>
>>>> 000
>>>>
>>>>  100
>>>>
>>>>   110
>>>>
>>>>   120
>>>>
>>>>  200
>>>>
>>>>   210
>>>>
>>>>    211
>>>>
>>>>   220
>>>>
>>>>    221
>>>>
>>>>    222
>>>>
>>>>    223
>>>>
>>>>   230
>>>>
>>>>
>>>>
>>>>
>>>> This is not the J concept of array, but something else.
>>>>
>>>>     Den søndag den 19. juli 2020 22.13.08 CEST skrev Devon McCormick <
>>>> [email protected]>:
>>>>
>>>>  Does anyone have a good way to display a tree in J?  EG
>>>> C:
>>>> |__n0
>>>> |  |_n00
>>>> |  |_n01
>>>> |
>>>> |__n1
>>>>     |__n10
>>>>     |  |__n100
>>>>     |__n11
>>>>     |  |__n110
>>>>     |  |__n111
>>>>     |  |__n112
>>>>     |__n12
>>>> for a tree in parent index form:
>>>>     tr=.  _1    0    0    1      1    2    2    2      5      6      6
>>>>     6
>>>>   nms=.
>>>> 'C:';'n0';'n1';'n00';'n01';'n10';'n11';'n12';'n100';'n110';'n111';'n112'
>>>> Where "tr" is the parent-index form (with _1 for the root) and "nms" are
>>>> the names of each node.
>>>>
>>>> Any other neat representation of a tree would also be appreciated.
>>>>
>>>> Thanks,
>>>>
>>>> Devon
>>>>
>>>> --
>>>>
>>>> Devon McCormick, CFA
>>>>
>>>> Quantitative Consultant
>>>> ----------------------------------------------------------------------
>>>> For information about J forums see http://www.jsoftware.com/forums.htm
>>>>
>>>> ----------------------------------------------------------------------
>>>> For information about J forums see http://www.jsoftware.com/forums.htm
>>>>
>>>> ----------------------------------------------------------------------
>>>> For information about J forums see http://www.jsoftware.com/forums.htm
>>>>
>>>
>>>
>>> --
>>>
>>> Devon McCormick, CFA
>>>
>>> Quantitative Consultant
>>>
>>>
>>
>> --
>>
>> Devon McCormick, CFA
>>
>> Quantitative Consultant
>>
>>
>
> --
>
> Devon McCormick, CFA
>
> Quantitative Consultant
>
>

-- 

Devon McCormick, CFA

Quantitative Consultant
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to