Hi,
On Mar 1, 2010, at 5:19 AM, Andrzej <[email protected]> wrote:
What to do if we don't know which of the equation variables are
unknowns? Let's say that the user may choose whether to input "Rent"
and "Sell", or "Rent" and "opportunityCost". I can imagine writing
some code like this:
(defn opportunity-cost [opportunity-cost-in rent-in sell-in]
(if (nil? opportunity-cost-in)
(- rent-in sell-in)
opportunity-cost-in))
(defn rent [opportunity-cost-in rent-in sell-in]
(if (nil? rent-in)
...)
(defn sell [opportunity-cost-in rent-in sell-in]
(if (nil? sell-in)
...)
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?
Going further, what to do if the equation is underspecified (for
example, if the user has only input "Rent") and we want to do
something more useful than just fail. This would require us to do the
calculations symbolically. Can Clojure help here somehow? What would
be a minimal CAS framework in Clojure?
This is a solver, which is standard functionality in a spreadsheet.
Obviously, writing a solver is much larger on scope than writing a
formula calculator where the list of inputs and functions us known at
compile design time.
I suspect cells can be used to implement this, though I haven't used
them. The problem seems very Prolog-y. I wonder if there are any such
frameworks already out there. This would be a great project for
contrib if not.
Thanks,
Johnny
--
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