Just from the hip.

   ;(<@(##{.);.2~ 1,~2>/\a:e.~])
'';'Hi';'';'';'Ho';'';'hee';'';'';'haw';'';'';'Yo';''
++--+--+--+--+--+---+---+---+---+---+---+--+--+
||Hi|Hi|Hi|Ho|Ho|hee|hee|hee|haw|haw|haw|Yo|Yo|
++--+--+--+--+--+---+---+---+---+---+---+--+--+


R.E. Boss


> -----Original Message-----
> From: [email protected] [mailto:programming-
> [email protected]] On Behalf Of Devon McCormick
> Sent: maandag 5 januari 2015 17:07
> To: J-programming forum
> Subject: [Jprogramming] Forward fill w/o looping
> 
> I just threw together a short J solution that does what I want but it uses
> a loop and a conditional.  I'm thinking there's got to be some kind of
> loopless prefix sort of solution but am at a loss to come up with it.
> 
> My code looks like this:
> 
> fillEmptyFwd=: 3 : 0
> for_ix. i.<:#y do.
>     if. 0=#>y{~>:ix do. y=. (ix{y) (>:ix)}y end.
> end.
> y
> )
> 
> An example usage would be this:
> 
>    fillEmptyFwd '';'Hi';'';'';'Ho';'';'hee';'';'';'haw';'';'';'Yo';''
> ++--+--+--+--+--+---+---+---+---+---+---+--+--+
> ||Hi|Hi|Hi|Ho|Ho|hee|hee|hee|haw|haw|haw|Yo|Yo|
> ++--+--+--+--+--+---+---+---+---+---+---+--+--+
> 
> Any ideas on something less loopy/conditional?
> 
> --
> Devon McCormick, CFA
> ----------------------------------------------------------------------
> 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