Hello list,

I'm just trying out Neko and benchmark it a bit :-)

A little question here: How to define recursive functions efficiently?
Something like:

var nfibs = function(n, func)
        {
        if n < 2
                return 1;
        else
                /* recursive calls */
                return func(n - 1, func) + func(n - 2, func) + 1;
        }

var i = 0;
while i <= 10  /* a for loop */
        {
        $print(nfibs(35, nfibs) + "\n");
        i += 1;
        }

I'm sure there is a better (and more performant) way of doing this. By
the way: is the above while-loop the easiest way to implement a for-loop?

I've also ported the n-body benchmark from the Great Programming
Language Shootout Game[1] maybe I'll submit it to them, could be fun :-)


Greetings and thanks,
Ernst Rohlicek jun.


[1]
http://shootout.alioth.debian.org/gp4sandbox/benchmark.php?test=nbody&lang=all



-- 
Neko : One VM to run them all
(http://nekovm.org)

Reply via email to