Re: [q-lang-users] Strong examples of Q equational programming wanted
Brought to you by:
agraef
From: Greg B. <gr...@sl...> - 2006-09-30 04:09:33
|
Albert Graef wrote: > Have you actually tried the Prolog solution? Yes. But I haven't tested it extensively, so there could be an error lurking in there. And the previous program isn't quite as functional as the Q version, since it doesn't automatically know how to normalize integer arithmetic, but a couple of extra lines could cure that... simp(X*Y,Z) :- integer(X),integer(Y), Z is X*Y, !. simp(X+Y,Z) :- integer(X),integer(Y), Z is X+Y, !. > It looks to me as if those rules only apply to the toplevel terms, so > some recursive descent would be needed. (In Q this is implicit because > of the evaluation strategy.) Hmm, I don't know if I see what you are saying. The simplification routine is interleaved with the recursive differentiation relation. Every time we reconstruct a term, we see if there is a simplification that applies. And I don't think any of the current reconstructions require more than one simplification to get rid of the extra 1 and 0 terms. Of course, if we tried to implement a fancier CAS this might not hold. Maybe you could provide an example of what you mean? Greg Buchholz |