Hi Jon,

> E.g. (fibo 8) returns 34, while that should have been the result of
> (fibo 9).
> The bugs in fibo and cachedFibo are in lines 6 and 30 where "(if (>
> 2 N)" should have been "(if (>= 2 N)".

Yes, I know. :)


> When this "=" got lost I don't know, but in picoLisp-2.3.5 these
> things are correct.

This is not a new "bug". I'm using "(if (> N 2)" since 30 years for such
simple benchmark purposes, so I didn't care to change. I don't remember
if I made this up by myself, of if I found it somewhere.


In any case it is a matter of definition, i.e. where you start counting
the fibonacci numbers. If you omit the initial zero, you get a proper
sequence starting with index '1' (as is the convention in PicoLisp):

   : (for N 7 (println N (fibo N)))    
   1 1
   2 2
   3 3
   4 5
   5 8
   6 13
   7 21
   -> 21


> The bugs are here as well:
> <http://rosettacode.org/wiki/Fibonacci_sequence#PicoLisp>

Right, in this place it should better not be used.



> Something else:
> The function 'bench' seems not to be available in pil32 and
> pil64emu. Why not make it available?

In fact it is. But in all systems you must switch on debug mode (with
the '+') to have it loaded:

   $ pil +
   : (pp 'bench)
   (de bench Prg
      (let U (usec)
         (prog1 (run Prg 1)
            (out 2
               (prinl
                  (format (*/ (- (usec) U) 1000) 3)
                  " sec" ) ) ) ) )
   -> bench



> And:
> I tried to start pil64emu this way: bin/picolisp misc/fibo.l
> .. but that gave me a "Segmentation fault".

I think it crashes because of the beta version. But the above call is by
itself also not wise, because it doesn't properly set up the runtime
environment needed for this file.

You should try

   $ ./pil misc/fibo.l

or at least

   $ bin/picolisp lib.l lib/misc.l misc/fibo.l

to have everything that's needed.

But it will also not work, because the 'native' function is still
missing in pil64emu.


> Have a nice weekend!

You and everybody else, too! :)

Cheers,
- Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

Reply via email to