Samuel Tardieu wrote:
> What would be the best way to implement the Fannkuch benchmark in J?

Analytically.

That said, I don't think anyone has come up with an analytic
solution, yet.

> From the shootout page (http://tinyurl.com/f3wdz):
...
> I'm surprised not to see J entries in the Shootout benchmark.

The J interpreter copyright does not satisfy the alioth shootout
requirements -- currently there are no implementations with
freely distributable and modifiable source.

Also, note that that benchmark has some rather silly requirements.
For example, it requires that permutations be generated in a
particular order.

Here's an example of a J program which satisfies the explicit
requirements of the shootout page, and which is about twice
as fast as the perl #2 solution listed on the shootout page,
but which does not generate permutations in the required order:

allpr=: [: >: i. A.~ [: i. !
out=: 1!: (&(<'output.file')) (@([:,LF,"1~":))
first=: {."[EMAIL PROTECTED]
nstep=:3 :0"0
 2 out 30{.prm=: allpr y
 pinds=:(i.>:y)(}. ,~ [: |[EMAIL PROTECTED] {.)"0 1 i.y
 n=:0
 while.#prm=:(#~1<first)prm do.
  n=:n+1
  prm=:pinds((first { [) {"1 ]) prm
 end.
 3 out n
)

Example use:
   nstep 7
   nstep 10

-- 
Raul

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to