Here’s my attempt at a constructive approach.  In haste, as Liz wants 
to get away from this WiFi spot!  So no time for explanation...  and I 
haven’t had an opportunity to digest Erland’s improvement to my 
improvement to Lippa Esu’s verb.  Sorry for brevity.

constructpart =: 3 : 0
:
d   =. y
m   =. x
r   =. ,. col =. i. d
nr  =. d#1         NB. size of nub of each row
done=. 1
SIZE=: 0
for_i. >: |. }: i.d do.
   nadd=. i * #r
   col =. nadd$i.i 
   r   =. i#r
   nr  =. i#nr
NB.    nr =. nr + col -.@e."0 1 r NB. less space but slower than... 
   nr  =. nr + *./"1 col ~: r
   if. m<: done =. >: done do.    NB. check row nub-sizes ok
      ok  =. nr <: m
      ok  =. ok * (nr < m) +. (nr = m) * i >: <./"1 r
      nr  =. ok#nr
      r   =. (ok#col),. ok#r
      col =. ok#col 
   else.
      r   =. col,. r
   end.
   SIZE =: SIZE >. #col    NB. for comparison with sizes in other 
approaches
end. 
~.i.~"1 r#~ m = #@~."1 r 
)

Its performance is somewhat worse in time,  comparable in space with my 
earlier efforts.  
I don't know about comparison with Erland's modification. 
No time for more - "can we make a move",  says Liz!

Mike

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

Reply via email to