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:29:34
|
Greg Buchholz wrote: > > Maybe you could provide an example of what you mean? OK, I took another look at symbolic.q and above the differentiation routine there are a few equations like... (X+Y)*Z = X*Z+Y*Z; X*(Y+Z) = X*Y+X*Z; X+(Y+Z) = (X+Y)+Z; X*(Y*Z) = (X*Y)*Z; ...In order to implement that, we'd have to add additional (recursive) relations like... simp((X+Y)*Z,A+B) :- simp(X*Z,A),simp(Y*Z,B). simp(X*(Y+Z),A+B) :- simp(X*Y,A),simp(X*Z,B). simp(X+(Y+Z),A+B) :- simp(X+Y,A), simp(Z,B). simp(X*(Y*Z),A*B) :- simp(X*Y,A), simp(Z,B). ...is that what you were hoping to see? The complete file is at... http://sleepingsquirrel.org/lisp/diff.prolog Greg Buchholz |