Here are some thoughts on a thread from early in September. This is a bug:
    
   p=: 13 : 'y+y'
   p
+
   p 5
5

But this does give the correct result:

    z=: 3 : '(i.1+y)!y'
    z
3 : '(i.1+y)!y'
    z 7
1 7 21 35 35 21 7 1

Now let 13 do the hard work:
   
   b=: 13 : '(i.1+y)!y'
   b
] !~ [: i. 1 + ]
   b 7
1 7 21 35 35 21 7 1

Then just act as though you knew it all along!
   
   b=: ] !~ [: i. 1 + ]
   b 7
1 7 21 35 35 21 7 1

Cheers. After three and a half years trying to sell my house in NJ I finally
sold it and moved to a condo in FL so I may have time to play again!


-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Devon McCormick
Sent: Friday, September 02, 2011 10:16 AM
To: Programming forum
Subject: Re: [Jprogramming] Wrong result from 13:

Is this bug the same as

   13 : 'y+y'
+

?

On Fri, Sep 2, 2011 at 7:07 AM, Raul Miller <[email protected]> wrote:

> On Fri, Sep 2, 2011 at 3:01 AM, Joey K Tuttle <[email protected]> wrote:
> > Happily, it gives the same result as oof (even though complicated and
> > obscure...)  My use of the temporary z was just sloppiness - but I
> > didn't notice that until I was flummoxed by making a tacit form -
> >
> >    hooft =: 13 : '+/"1 ((i.y+1) =/ +/"1 z) [ z =. #: i. 2^y'
> >
> > and discovering that it produces a very different result (displaying
> > the shape is sufficient to show that without wasting space).
> >
> >    $hooft 6
> > 7 64 7
> >
> > So clearly, 13 : failed. This rings a bell of something similar being
> > reported before, but maybe it is different. I haven't succeeded in a
> > simple expression that goes wrong in the same way. I'm sure someone
> > in the forum can provide a tacit form that is similar, but works
> > correctly - something other than -
>
> You can make that long expression tacit by breaking out the expression
> which finds z:
>   13 : 'z =. #: i. 2^y'
> [: #: [: i. 2 ^ ]
>
> At this point the remaining expression has two variables: y and z.
> This suggests using a hook for a monadic context.  So we can replace y
> wiith x and z with y:
>
>   13 : '+/"1 ((i.x+1) =/ +/"1 y)'
> [: +/"1 ([: i. 1 + [) =/ [: +/"1 ]
>
> And then we plug the two phrases back into the parenthesis of (() ()):
>
>   (([: +/"1 ([: i. 1 + [) =/ [: +/"1 ])([: #: [: i. 2 ^ ])) 6
> 1 6 15 20 15 6 1
>
> Also, here is a simpler expression which probably illustrates the same
> problem:
>
>   '; ((y+1) ; , z) [ z =. 2+y'
>
> I found this by defining:
>   expr=: 1 :'((3 :m),&<(13 :m))'
>
> And then experimenting with sentences like:
>   $&.> 'experiment' expr 6
> until I had found a short one and then switching to
>   'experiment' expr 3
> to simplify it further.
>
> FYI,
>
> --
> Raul
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>



-- 
Devon McCormick, CFA
^me^ at acm.
org is my
preferred e-mail
----------------------------------------------------------------------
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