> Alternative (slightly more compact) implementation of tv:
> 
>    tv=: (0 = {.) *./@, (0 < {:), 1 >: +/\inv

Nice way to factor out the (*./) redundancy. Thanks.

> Meanwhile, this is probably a bit long (almost 100 characters) to be
> called a one line implementation, but it seems to be in the right
> ballpark:
> 
>    ;"1(' -  ',&.>' o+|'){~(+3*_1 1&E.)"1&.|:(*
> >./\.@:*)0,~2:`(}.@((i:,.]-1:) ~.))`((1,~]#_1:)"0)}~d
> -o
>  |-o
>  | |-o
>  | +-o
>  |-o
>  +-o
>    |-o
>    +-o
>      +-o

Argh. Reading this made me smile. I really like several of the ideas in here,
especially the use of boxing to select character pairs at the end. Also, the
(_1 1&E.) is such a compact edge detector, but unfortunately in this case, it's
not quite enough:

       tp=: ;"1(' -  ',&.>' o+|'){~(+3*_1 
1&E.)"1&.|:(*>./\.@:*)0,~2:`(}.@((i:,.]-1:) ~.))`((1,~]#_1:)"0)}~
       d=: 0 1 2 3 1
       tp d
    -o
     |-o
     | +-o
     | + +-o
     +-o

The problem is that detection of branch endpoints isn't locally determined; we
have to look arbitrarily far ahead. This is the "catenary problem" I mentioned.

I'm going to have some fun stealing your ideas.

Cheers!
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to