Your sample data does not match your problem description.

That said,

   {.@(_&".)"1 > ' ';'bad';'10'
0 _ 10

Thanks,

-- 
Raul


On Fri, Apr 13, 2018 at 2:03 PM, Joe Bogner <joebog...@gmail.com> wrote:
> I have a large byte array that I want to convert to a number array. I want
> to use _ to indicate a bad value, but blank should be treated as 0
>
>   $ c
> 4862343 10
>
> Instead of this:
>
> asnumber =: _&".
>
>    asnumber  (>' ';'bad';'10')
> _ _ 10
>
> I want this:
>
>
>    asnumber  (>' ';'bad';'10')
> 0 _ 10
>
> This works, but is much slower than I'd like -- nearly 3x slower than just
> _ ".
>
>    asnumber =: _ ". '0' ,~^:([: */ ' '&=@])"1  ]
>    asnumber  (>' ';'bad';'10')
> 0 _ 10
>
>    (6!:2) 'asnumber c'
> 3.32579
>    (6!:2) '_&". c'
> 1.35091
>
>
> I have an isblank function that is fast
>
>    isblank =. ([: ({. -:"1 }.) ' '&,)
>    (6!:2) 'isblank c'
> 0.033164
>
> I can't seem to combine the two into something that performs well without
> doing things at the atom/row level instead of the entire array. I suspect
> I'm getting tripped up by rank
> ----------------------------------------------------------------------
> 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