Re: eval performance

2009-12-23 Thread Brian Goslinga
If you are doing GP, another approach to avoid using eval would be using a tree of closures. http://xach.livejournal.com/131456.html is an example of the technique used in Common Lisp (should be similar enough). -- You received this message because you are subscribed to the Google Groups "Clojur

Re: eval performance

2009-12-22 Thread kyle smith
I haven't touched it in a while, but I'm going to pick it back up soon. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient wi

Re: eval performance

2009-12-22 Thread Gabi
Superb! This is exactly what I needed.. A way to get rid of the awkward intern and boost performance. Have you progressed far with your GP experimenting ? On Dec 22, 4:17 am, kyle smith wrote: > Here's the macro I used when I dabbled in Genetic Programming: > > user> (time (dotimes [_ 1000]

Re: eval performance

2009-12-21 Thread Graham Fawcett
On Mon, Dec 21, 2009 at 6:07 PM, Gabi wrote: > The problem with is that I need to execute the same function with > different bindings each time. So caching won't help me > For example I need to do something like: > > (dotimes [_ 1000] >  (intern  'user 'x (rand)) >  (eval '(prn (+(* x x) 5 So

Re: eval performance

2009-12-21 Thread kyle smith
Here's the macro I used when I dabbled in Genetic Programming: user> (time (dotimes [_ 1000] (intern 'user 'x (rand)) (eval '(+ (* x x) 5 "Elapsed time: 425.754877 msecs" user> (defmacro capture-vars [vars expr] `(fn [...@vars] ~(first (next expr #'use

Re: eval performance

2009-12-21 Thread Gabi
The problem with is that I need to execute the same function with different bindings each time. So caching won't help me For example I need to do something like: (dotimes [_ 1000] (intern 'user 'x (rand)) (eval '(prn (+(* x x) 5 On Dec 21, 11:53 pm, AlexK wrote: > What eval does, is wra

Re: eval performance

2009-12-21 Thread Meikel Brandmeyer
Hi, Am 21.12.2009 um 22:53 schrieb AlexK: > (defn form->fn [list-to-eval] > (eval (list 'fn [] list-to-eval))) ;this returns a fn Please, make it a habit of writing even such simple code as `(fn [] list-to-eval) (or `(fn [] ~...@list-to-eval) if list-to-eval is a Var or a local). If you make

Re: eval performance

2009-12-21 Thread Gabi
Experimenting with GeneticProgramming with Clojure.. On Dec 21, 11:23 pm, rob wrote: > Sorry, I somehow accidentally sent it before I was done typing.  The > rest of my sentence was "what are you trying to do thar requires the > use of evals in that way". > > On Dec 21, 4:22 pm, rob wrote: > > >

Re: eval performance

2009-12-21 Thread AlexK
What eval does, is wrapping (fn* [] ) around its arguments, compiling that, and calling the resulting function object (except if your list starts with a 'do or a 'def). While Clojure's compiler is pretty fast, you should try not to use eval. If you want to pass code around you should try something

Re: eval performance

2009-12-21 Thread rob
Sorry, I somehow accidentally sent it before I was done typing. The rest of my sentence was "what are you trying to do thar requires the use of evals in that way". On Dec 21, 4:22 pm, rob wrote: > It sounds like your use of evals might be something that could be done > better using a more idioma

Re: eval performance

2009-12-21 Thread rob
It sounds like your use of evals might be something that could be done better using a more idiomatic clojure approach. What are you trying to do that re On Dec 21, 2:32 pm, Gabi wrote: > Hi > I have this program that needs to do many eval's to same expression > (eval '(some-list-to-execut..)) >

Re: eval performance

2009-12-21 Thread rob
It sounds like your use of evals might be something that could be done better using a more idiomatic clojure approach. What are you trying to do that re On Dec 21, 2:32 pm, Gabi wrote: > Hi > I have this program that needs to do many eval's to same expression > (eval '(some-list-to-execut..)) >

eval performance

2009-12-21 Thread Gabi
Hi I have this program that needs to do many eval's to same expression (eval '(some-list-to-execut..)) My question is how can this be optimized ? Does eval compile the evaled expression ? Does it re-compile the evaluated expression again and again? Maybe I could compile the evaled expression once