Re: [q-lang-users] Strong examples of Q equational programming wanted
Brought to you by:
agraef
From: Albert G. <Dr....@t-...> - 2006-09-30 00:46:52
|
Have you actually tried the Prolog solution? 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.) Greg Buchholz wrote: > ...and a Prolog solution... > > > diff(X,X,1). > diff(U+V,X,Z) :- diff(U,X,Up), diff(V,X,Vp), simp(Up+Vp,Z),!. > diff(U*V,X,C) :- diff(U,X,Up), diff(V,X,Vp), > simp(U*Vp,A), simp(V*Up,B), simp(A+B,C),!. > diff(_,X,0). > > simp(0*X,0). > simp(X*0,0). > simp(1*X,X). > simp(X*1,X). > simp(0+X,X). > simp(X+0,X). > simp(X,X). -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikinformatik.uni-mainz.de/ag |