lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Luiz Henrique de Figueiredo <> wrote:
> >I suppose that you could also write something
> >to turn these structures into a string and call dostring() but then you've
> >got the whole code structure -> text -> compiled code that scheme avoids.
> I don't get it. Why convert the tables into strings??

I meant convert them to their code equivalent and compile it so it will
execute faster. For example:
  7 + ( 4 * 3 )

executes faster than:



So make a function that turns:



 myFunc = dostring("return function () return args.1 + ( args.2 * args.3 )")

and precompile it. Then execute it with the current args:

 result = myFunc({7,4,3})

This is important for genetic algorithms because we typically run the
same genome's algorithm over large data sets. (In my application I'm
running each genome on about quater of a million data points to evaluate 
it's fitness - this has to be done for 100s of genomes for 100s of generations)