but complexity of such expressions quickly grows as dependencies
between variables become more complex. Is there any
technique/framework for handling such calculations automatically? I
have a vague impression that this is what logic programming languages
are about. How would one implement such calculations in Clojure?

As Johnny mentioned: this is a solver. Doing it in Clojure means writing something rather more complicated than a simple calculator! Clojure is not a logic programming language.

You might find a cell/dataflow framework useful, which essentially gives you spreadsheet-like dataflow:

  <http://richhickey.github.com/clojure-contrib/dataflow-api.html>

best introduced in its original Common Lisp form:

  <http://smuglispweeny.blogspot.com/2008/02/cells-manifesto.html>

but you'll still have to do some manual decision-making. (Just like in a spreadsheet, you have to write the formulae...)

You might also (depending on how things fall out) find some kind of table-based or multimethod-based approach to be adequate (e.g., making two different kinds of `sell` evaluation based on whether some value is nil). That will reduce the number of explicit branches in your code.

If neither of those helps, then your best bet is to spend a little time with, say, Mathematica, Excel, and Prolog (or one of its successors). Those might well be better systems for handling this kind of web of dependencies.

If you want a Lisp syntax for Prolog, try Allegro Common Lisp.

http://www.franz.com/products/prolog/index.lhtml

--
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 with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to