Hi,
Thanks for both answers. I will try to find the relevant text in Joy of
Clojure (I have access to the first edition).
I followed the expresso <https://github.com/clojure-numerics/expresso>
link, but I am not interested in mathematical expressions.
Refining my question: I am more interested in the programming aspects of
Mathematica (or to its descendant Wolfram Language). In the eval case, a
better example would be (a is unbound):
(def b 1)
(eval-partial '(+ (+ 8 2) a (* 9 (+ 2 b))))
--> '(+ 37 a)
Eval-partial would return a Lisp expression with unbound symbols.
The expression being evaluated could be quite complex.
With eval-partial, I would like to be able to have complex functions
that depend on results that aren't ready yet. They would evaluate
(partially) to expressions that could be re-evaluated later, to see if all
the symbols they depend upon are ready (bound). I intend to use this
technique to write more flexible DSLs.
BTW, if expresso can do some similar to this, I am willing to give it a
second look.
Any ideas?
Cheers,
Dilvan.
On Friday, June 13, 2014 6:46:56 PM UTC-3, Dilvan wrote:
>
> Hi all,
>
> I'm a novice to Clojure (but not to programming).
> I'm looking for an implementation of an eval function to eval
> expression like Mathematica does.
> For instance, in Mathematica the expression:
>
> 8 + a + 9 (2 + b) + 2
>
> if a and b are not bound, translates to
>
> Plus[10, a, Times[9, Plus[2, b]]]
>
> if a and b become bounded later (let say to 1 and 2) and the expression
> is evaluated again, it returns 47.
>
> I would like to be able to run:
> (eval-partial '(+ (+ 8 2) a (* 9 (+ 2 b))))
> and get, if a and b are unbound:
> (fn [x y] (+ 10 x (* 9 (+ 2 y))))
> or (better still)
> ['(a b) (fn [x y] (+ 10 x (* 9 (+ 2 y))))]
> Notice that, whenever possible, the eval takes place and parts of the
> expression are evaluated (in the example above, the expression (+ 8 2) is
> evaluated to 10).
>
> If you know of any implementation or have any ideas on the subject,
> please let me know.
>
> Cheers,
> Dilvan.
>
>
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.