I can reproduce the bug and I'll look into it.
Basically the header of the matrix m is messed up.

   tclose=: 3 : '{&y^:a:i.#y'
   ]m=: |.tclose ?.1>.i.10
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 1 0 1 1 0
0 0 0 0 1 2 1 2 2 1
0 0 1 1 2 4 2 4 4 2
0 1 2 3 4 5 6 7 8 9
   ({:@{: -: {:@,) m
0
   {:m  NB. wrong!
7 8 9 0 0 0 0 0 0 0 0
   6 {. 0 (3!:3) m
e0000000
00000004
0000003b
00000002
00000005
0000000a
   6 {. 0 (3!:3) i.$m
e0000000
00000004
00000032
00000002
00000005
0000000a
   
The element count should be 0x32 in both cases,
but in m it is incorrectly 0x3b .



----- Original Message -----
From: Raul Miller <[EMAIL PROTECTED]>
Date: Thursday, March 13, 2008 10:30
Subject: Re: [Jprogramming] tree sum and difference
To: Programming forum <[email protected]>

> (I think this message constitutes a spoiled spoiler..)
> 
> On 3/13/08, Roger Hui <[EMAIL PROTECTED]> wrote:
> > What was the solution you anticipated?
> 
> I was cleaning up my solution for presentation
> purposes, and I ran into a problem:
>    tclose=: 3 : '{&y^:a:i.#y'
>    ]m=: |.tclose ?.1>.i.10
> 0 0 0 0 0 0 0 0 0 0
> 0 0 0 0 0 1 0 1 1 0
> 0 0 0 0 1 2 1 2 2 1
> 0 0 1 1 2 4 2 4 4 2
> 0 1 2 3 4 5 6 7 8 9
>    _1{|.tclose ?.1>.i.10
> 7 8 9 0 0 0 0 0 0 0 0
>   ({:@{: -: {:@,) m
> 0
> 
> This happens to me in both J601 and J602, and I do not
> understand why I was not having this problem earlier,
> and I have already overwritten my earlier versions of
> my code.
> 
> Also, I am now having similar problems with for loops.
> 
> Anyways, my basic approach might have been expressed
> something like this (except that this does not work)
>    trmerge=: ([EMAIL PROTECTED]@] , [) <@~.@;/. ,[EMAIL PROTECTED]
>    trinds=: trmerge/@|[EMAIL PROTECTED]
>    trsum=: <@[ +/@:{~&> [EMAIL PROTECTED]
>    (?.100+i.10) trsum ?.1>.i.10
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to