|
From: | Ralf Hemmecke |
Subject: | Re: [Axiom-math] if-expression and variables |
Date: | Wed, 04 May 2011 20:02:18 +0200 |
User-agent: | Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110414 Thunderbird/3.1.10 |
The first questions, when one programs with Axiom usually are: What is my "domain of computation"? (That is basically like with universal algebra. What is the carrier set and what are the operations?) How are the elements of the carrier set represented in terms of already existing (library) types?Yes, I think it boils down to second-order logic; in this case a category of unevaluated expressions. As above; stored in the tree and then brought front and center and evaluated in the tree accessing environment.
As I said, it's no problem to implement that in Axiom. Actually, InputForm is basically such a domain.
Going back to the original question. It seems the questioner expects to fabricate a template and later to create instances of it with varying variables.
Although possible, that is a mindset that belongs to traditional (typeless) CAS. I would rather ask the questioner to state the actual problem instead of already giving a direction, i.e. using expression trees.
Sorry if I have taken the discussion drifting; I merely wanted to point out the if/else can be a static data structure rather than in-line code.
Well, of course, that's possible. In fact, expression trees is something that almost all computer algebra systems rely upon. But Axiom is different.
Take for example 1+1. What is this evaluated? Three out of infinitely many results. 1) 2 2) 0 3) 1+1In Axiom (at least in SPAD) there would only be one possible result, since the compiler checks types. If it is clear what 1 and + means, it's also deterministic what the result is.
Ralf
[Prev in Thread] | Current Thread | [Next in Thread] |