On 11 October 2011 18:29, Mike Day <mike_liz....@tiscali.co.uk> wrote:
> ...............
> Run
>    x: +/ sumq >: i. 12000     NB. very nearly a spoiler

    Mike,
I haven't read your solution in detail, but was curious to try it, and got
the following:

      x: +/ sumq >: i. 12000
|domain error: sumq
|   x:+/    sumq>:i.12000


On ......... I wrote:
>   f 12000
> .................
> ...... very slow for 12000: almost 2 min on my computer.

I implemented the same algorithm on several other interpreted
languages and ran it on the same machine as my J solution.
All were significantly faster than J at 12000:
    Rebol           – 19s,
    CLisp           – 16s,
    PostScript      – 9s,
    Lua, Python     – 6.5s,
    Ruby            – 3s,
    Scheme (Racket) – less than 0.5s!

J is often amazingly fast at whole-array (non-iterative) operations,
but seems to be rather unfavourable to iterative (including recursive)
ones.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to