Terrence Brannon wrote:

> ...
> The actual code I wrote is here:
>
>http://hg.metaperl.com/alioth?f=41c39cfb6ff3;file=recursive;style=raw
>
> ...
> Remember these are supposed to be naive
implementations.
>

As discussed this weekend, it does seem to me that the
first two verbs on the Fibonacci Sequence wiki page
fit the requirement.  Raul was the first to point to
those.

http://www.jsoftware.com/jwiki/Essays/Fibonacci_Sequence

There is, of course, real value in coding something
for oneself.  I think it was better that you did so,
than if you had drawn from the examples.

Here is what I got comparing execution time (and
space) between your code and verb f0b from the wiki
article:

   t =: 3 : 'y > 1'
   fib =: base_case ` rec_case @. t
   rec_case =: 3 : '( fib (y-1) ) + ( fib (y-2) )'
   base_case =: 1:

   fib 27
317811
   ts 'fib 27'
5.83076 48576

   f0b=: (-&2 +&$: -&1) ^: (1&<)

   f0b 28
317811
   ts 'f0b 28'
1.20082 13312
   


       
____________________________________________________________________________________Be
 a better Globetrotter. Get better travel answers from someone who knows. 
Yahoo! Answers - Check it out.
http://answers.yahoo.com/dir/?link=list&sid=396545469
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to