Re: creating a function from a sexp

2010-10-27 Thread Sunil S Nandihalli
actually i am able to find a few examples ... from a google group thread... http://groups.google.com/group/clojure/browse_thread/thread/d710c290b67951a3/b827d46389110f26?lnk=gst&q=clojure+macro+%26env#b827d46389110f26

Re: creating a function from a sexp

2010-10-27 Thread Sunil S Nandihalli
Hi Nicolas, Thanks for you response. This is an experimental work. Knowing that there was clojuratica to link to mathematica .. I was hoping that we can generate the code to solve PDE .. This is an experimental thing .. But been having a lot of trouble in getting the basic stuff setup .. being ab

Re: creating a function from a sexp

2010-10-27 Thread nicolas.o...@gmail.com
You need to use both eval and a macro to get then environment. I think &env contains the lexical environment in any macro call now. (I don't know in each form though). So you need to walk the term, looking for free variables, close under free variables by creating a function and then call eval. Th

Re: creating a function from a sexp

2010-10-27 Thread Sunil S Nandihalli
not really the problem is that the s-expression is passed I don't know it ahead of time during compilation .. it is known at run-time... On Wed, Oct 27, 2010 at 6:54 PM, Ulises wrote: > > Is it possible to write such a function? > > Perhaps you're looking for partial? > > user> (def x 10) > #'us

Re: creating a function from a sexp

2010-10-27 Thread Ulises
> Is it possible to write such a function? Perhaps you're looking for partial? user> (def x 10) #'user/x user> (let [y 5] (partial + x y)) # user> ((let [y 5] (partial + x y)) 1) 16 user> U -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to

creating a function from a sexp

2010-10-27 Thread Sunil S Nandihalli
Hello everybody, I would like to create a function from an arbitrary s-expression for example if I have something like (def x 10) (let [y 20] (create-fn-from-sexp '(+ x y z))) I would like create-fn-from-sexp to return a function which is a function of the third argument z .. since both x and