Re: generating a fn with a body based on user inputs, possible?

2010-01-11 Thread tristan
Thanks for the notes Meikel, i'm a clojure newbie so this sort of advice in invaluable to me! On 8 Jan., 16:00, Meikel Brandmeyer wrote: > Hi, > > On Jan 8, 3:10 pm, tristan wrote: > > > I've been working on a problem where I want the user to be able to > > input an equation in infix notation wh

Re: generating a fn with a body based on user inputs, possible?

2010-01-09 Thread Meikel Brandmeyer
Hi, On Jan 8, 3:10 pm, tristan wrote: > I've been working on a problem where I want the user to be able to > input an equation in infix notation which includes variables and > convert that to a clojure fn that my program can call later. You need to construct the form of the function explicitely

Re: generating a fn with a body based on user inputs, possible?

2010-01-08 Thread tristan
Thanks Chouser! I had not thought of moving the (list 'fn ...etc) bit into the eval statement, it works perfectly! here is the final result! http://github.com/tristan/modelmaker/blob/d7dbdfa9b998cfc6b846ea5c235b4496ed8caa63/infix_parser.clj .Tristan On 8 Jan., 16:15, Chouser wrote: > On Fri, Jan

Re: generating a fn with a body based on user inputs, possible?

2010-01-08 Thread Chouser
On Fri, Jan 8, 2010 at 9:10 AM, tristan wrote: > > At first I thought I had solved it, as calling (parse-infix "a*(b+c)") > returned the desired function that i could call. However as soon as i > attempted to use it in the form (parse-infix users-input) it falls > over with a "Don't know how to cr

Re: generating a fn with a body based on user inputs, possible?

2010-01-08 Thread Laurent PETIT
Hello, parse-infix, being a macro, works on the code-as-datastructure it has as arguments. So (parse-infix x) receives the symbol x , unevaluated, is in charge of returning a new datastructure (generally involving the symbol x). Only then, the compiler will evaluate the result of having called pa

generating a fn with a body based on user inputs, possible?

2010-01-08 Thread tristan
Hi guys, I've been working on a problem where I want the user to be able to input an equation in infix notation which includes variables and convert that to a clojure fn that my program can call later. i.e. the user inputs the string "a*(b+c)" and i generate the unnamed function (fn [a b c] (* a