Sparse arrays have a default value:

   0 $. i.3
1 │ 1
2 │ 2
   4 + 0 $. i.3
1 │ 5
2 │ 6
   $.inv 4 + 0 $. i.3
4 5 6


... which seems to be leaking in here.

Thinking about that, I am sort of surprised that my variant does not
suffer from this same issue.

Thanks,

-- 
Raul


On Thu, Nov 9, 2017 at 1:54 PM, robert therriault <[email protected]> wrote:
> Well I thought I had a prettier version.
>
>    numeric1=:(0 -: {:)@:(0 # ,)
>    numeric1 'a'
> 0
>    numeric1 4 5 $ 'a'
> 0
>    numeric1 i. 4 5
> 1
>    numeric1 x: i. 4 5
> 1
>
> But then Raul's example of sparse arrays failed
>
>    numeric1 4+0 $.i.3
> 0
>
> The first part seemed to work as expected
>    (0#,) 4+0 $.i.3
>    $(0#,) 4+0 $.i.3
> 0
>
> So I assigned it to a variable which looked empty as expected...
>    t=.(0#,) 4+0 $.i.3
>    t
>    $t
> 0
>
> but then this!
>
>    {:t
> 4
>
> Anyone know how an empty list can have a last item?
>
> Confused, bob
>
>> On Nov 9, 2017, at 10:15 AM, Raul Miller <[email protected]> wrote:
>>
>>  isnumeric 4+0 $.i.3
>
> ----------------------------------------------------------------------
> 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