Thanks Roger,

I guess this is why we race Ferrari's and go shopping in minivans. :)

My first draft survives repeats, but I still find Arie's version beautiful (and 
functional within the specs of not having repeated items).

   t0=:((>.|."1)@(*=)@:>:@i.@#){ ' ',]
   t0 'abcde'
a   a
 b b 
  c  
 d d 
e   e
   t0 'abbbbccddde'
a         a
 b       b 
  b     b  
   b   b   
    b b    
     c     
    c c    
   d   d   
  d     d  
 d       d 
e         e

With improvements suggested by Arie's version,

t1=:(+.|.)@=@i.@#{"0 1 ' '&,.
   t1 'abcde'
a   a
 b b 
  c  
 d d 
e   e
   t1 'abbbccdde'
a       a
 b     b 
  b   b  
   b b   
    c    
   c c   
  d   d  
 d     d 
e       e
   
Cheers, bob

ps. Some day I will avoid the trap of repeated items and Self Classify (monadic 
=) 
On 2012-12-10, at 10:21 AM, Roger Hui wrote:

> The expression fails if the argument has duplicate items. e.g.
> 
>   ((+.|.)@={"0 1 ' '&,.)'aabbb'
> |length error
> |       ((+.|.)@={"0 1' '&,.)'aabbb'
> 
> 
> 
> On Mon, Dec 10, 2012 at 10:18 AM, bob therriault <bobtherria...@mac.com>wrote:
> 
>> That is lovely Arie,
>> 
>> It is that kind of elegance that I was chasing with my rougher attempts.
>> 
>> Using the (+.|.) hook simplifies (|.+.]) precisely and the {" 0 1
>> combined with ' '&,. means that the selection of the string becomes a
>> choice in each row of displaying either the corresponding element of the
>> string or a blank.
>> 
>> Cheers, bob
>> 
>> On 2012-12-10, at 1:11 AM, Aai wrote:
>> 
>>> ((+.|.)@={"0 1 ' '&,.)'abcde'
>> 
>> ----------------------------------------------------------------------
>> 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

Reply via email to