...and you should use

fib=: 3 : 0
if. y e. 0 1 do. y else. (fib y-1) + fib y-2  end.
)

to get the same results. Otherwise your fib is one ahead.

   ts 'fib 35'
305.701 51968


An advantage of Haskell in this is the use of type Int, notice the difference:

with type Int:

*Main> fib 35
9227465
(50.37 secs, 2454360728 bytes)


with type Integer

*Main> fib 35
9227465
(76.86 secs, 2884656900 bytes)




> To be more precise you should execute:
>  
>    ts 'fib"0 i.35'
>
>
>
> R.E. Boss schreef:
>   
>> 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
>>
>> Is anybody capable of comparing J-figures with (some of) the other languages
>> (except for parallel Haskell) on one machine?
>>
>>
>> R.E. Boss
>>
>>
>>
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
>>
>>
>>   
>>     
>
> ----------------------------------------------------------------------
> 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