You are right and if you want fast fib's, look at
http://www.jsoftware.com/jwiki/Essays/Fibonacci_Sequence 

But I wanted a solution as close as possible to those used in the other
languages.

Perhaps the conclusion should be: don't use J (as your first choice) for non
memoized recurrent solutions.


R.E. Boss
 

> -----Oorspronkelijk bericht-----
> Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Namens Viktor Cerovski
> Verzonden: donderdag 3 januari 2008 15:37
> Aan: [email protected]
> Onderwerp: Re: [Jgeneral] Performance comparison
> 
> 
> 
> R.E.  Boss wrote:
> >
> > In http://www.jsoftware.com/pipermail/chat/2008-January/000869.html  the
> > link http://cgi.cse.unsw.edu.au/~dons/blog is mentioned, at the end of
> > which
> > I found
> >
> >     Language Time (N=36)
> > Ruby (1.8.5)  64.26s
> > Python (2.4)  25.16s
> > Haskell (GHC 6.8)   0.48s
> > Parallel Haskell (GHC 6.8)   0.42s
> >
> > This was for the most 'naive fibonacci algorithm':
> >
> > fib=: 3 : 0
> > if. y e. 0 1 do. 1 else. (fib y-1) + fib y-2  end.
> > )
> >
> > On my machine I got
> >
> >     ts'fib 35'
> > 213.43542 52736
> >
> Directory entry for M. gives a very fast program:
> 
> fib=: 3 : 0 M.
>  if. 1>:y do. y else. (fib y-1)+fib y-2 end.
> )
> and that will speed up 'fib 35' about 10000 times,
> which should be considerably faster than all other programs
> from your list.
> 
> Possibly even faster code, especially if you want all the
> Fibonacci numbers below and including the 35-th, is:
> 
> (,[EMAIL PROTECTED])^:34(1 0)
> 
> --
> View this message in context: http://www.nabble.com/Performance-
> comparison-tp14595315s24193p14597960.html
> Sent from the J General mailing list archive at Nabble.com.
> 
> ----------------------------------------------------------------------
> 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