Thanks very much for that, they are alot better! Although you were
missing the 'x', for the precision!
My final code is
    >:+/([:+/]-(i.4)*_1+%:)"0 *:>:+:>:i.500x

I might try refactor it, because: *:>:+:>:i.500x, is ugly.

And when I said the tacit form returned boxes, I might when I looked
at the verb it was boxed.
You showed:
      ]ft2 =: 13 : 'x:+/y -(i.4)* _1+%:y'
[: x: [: +/ ] - 0 1 2 3 * _1 + %:

But for me, this happens:
      ]ft2 =: 13 : 'x:+/y -(i.4)* _1+%:y'
+-+----------------------------------------------+
|]|+--+--+--------------------------------------+|
| ||[:|x:|+--+-----+---------------------------+||
| ||  |  ||[:|+-+-+|+-+-+---------------------+|||
| ||  |  ||  ||+|/|||]|-|+-------+-+---------+||||
| ||  |  ||  |+-+-+|| | ||0 1 2 3|*|+--+-+--+|||||
| ||  |  ||  |     || | ||       | ||_1|+|%:||||||
| ||  |  ||  |     || | ||       | |+--+-+--+|||||
| ||  |  ||  |     || | |+-------+-+---------+||||
| ||  |  ||  |     |+-+-+---------------------+|||
| ||  |  |+--+-----+---------------------------+||
| |+--+--+--------------------------------------+|
+-+----------------------------------------------+

*I know the formatting is lost, but I think you can get the idea.
So can I just write out that box, and it will work?

Thanks,
Joey

On Dec 3, 2007 1:55 AM, Sherlock, Ric <[EMAIL PROTECTED]> wrote:
>
> ---Joey wrote:
> > I am using that particular code here:
> >     f =: 3 : 'x:+/y -(i.4)*] (%:y)+_1'
> >     1++/f"0 *:>:2*>:i.500
> > Which is #28 on Project Euler, which I am using to learn J!
> >
> > I tried f =: 13 : 'x:+/y -(i.4)*] (%:y)+_1', then f; but the
> > result was boxed, and I wasn't sure how it should be formatted.
> > So how can I replace the definiton of f, into 1++/f"0 *:>:2*>:i.500.
> > And are there any things I am doing wrong in my code?
> >
> > Thanks,
> > Joey
> >
>
> I haven't looked at the problem you're trying to solve but some minor
> improvements to your posted code ...
>   f =: 3 : 'x:+/y -(i.4)*] (%:y)+_1'  NB. your explicit verb
>
>   1++/f"0 *:>:2*>:i.500
> 669171001
>
> I'm not sure why you were getting boxed results from the tacit
> representation of your explicit verb, it seems to work OK for me.
>   ft =: 13 : 'x:+/y -(i.4)*] (%:y)+_1'
>   1++/ft"0 *:>:2*>:i.500
> 669171001
>
> The tacit representation looks like this:
>   ft
> [: x: [: +/ ] - 0 1 2 3 * [: ] _1 + %:
>
> You can simplify the explicit version a bit which will also simplify the
> tacit version as follows:
>   ]ft2 =: 13 : 'x:+/y -(i.4)* _1+%:y'
> [: x: [: +/ ] - 0 1 2 3 * _1 + %:
>
>   1++/ft2"0 *:>:2*>:i.500
> 669171001
>
> And the constants could be replaced by some J verbs.
>   >:+/ft2"0 *:>:+:>: i.500
> 669171001
>
> If you are wanting to incorporate the definition of ft2 into the
> sentence I think I would just do:
>   >:+/([: +/ ] - (i.4)*_1+%:)"0 *:>:+:>:i.500
> 669171001
>
>
> Now that I see what the problem is from Roger's post, another way of
> phrasing the solution might be:
> diags=: 3 : 0
>  'difs trs'=. |:}. i. 2,~ >.-: y
>  trs=. *: trs
>  >:+/,trs (-(i.4)&*)"0 difs
> )
>   diags 5
> 101
>   diags 1001
> 669171001
>
> I'm sure there are other more concise ways!
>
>
>
> ----------------------------------------------------------------------
> 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