The problem stems from
$ ". ''
0
which tells you that empty array in gives you a list result.
So, when you apply ". every to an empty boxed list, it will
apply ".&> on a cell of fills, which will run ". on an
empty list, which will return a list, which will have a leading
0 appended to the shape. Shape 0 0.
You want a verb that returns an atom no matter what its input, right?
${.@(0&".) every '[[:digit:]]+' rxall 'asdhrf'
0
${.@(0&".) every '[[:digit:]]+' rxall 'asd345hrf2'
2
Henry Rich
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of June Kim
> Sent: Saturday, July 05, 2008 11:31 AM
> To: Programming forum
> Subject: [Jprogramming] shape of do on an empty array
>
> $ "."0 '123'
> 3
> $ "."0 '12'
> 2
> $ "."0 '1'
>
>
> So far, I follow it.
>
> $ "."0 ''
> 0 0
> $0&"."0 ''
> 0 0
>
> Now, I don't understand the rationale behind the result. Why should it
> suddenly become a 2-dimensional array?
>
> This becomes a problem when I have to "do every" (".&>) on a boxed
> array or an empty array(''). Since the resultant arrays are irregular,
> I have to put code to treat the exception.
>
> Suppose the following case:
> load 'regex'
> $".every '[[:digit:]]+' rxall 'asdhrf'
> 0 0
> $".every '[[:digit:]]+' rxall 'asd345hrf2'
> 2
> +/".every '[[:digit:]]+' rxall 'asdhrf'
>
> $+/".every '[[:digit:]]+' rxall 'asdhrf'
> 0
> +/ ".every '[[:digit:]]+' rxall 'asd345hrf2'
> 347
>
> Because of it, I can't use the nice default of +/ on empty arrays:
>
> +/ ''
> 0
> +/ 0 0$''
>
>
> And further down, the empty value isn't very useful.
> ----------------------------------------------------------------------
> For information about J forums see
> http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm