Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!rutgers!im4u!milano!varghese From: varghese@milano.UUCP Newsgroups: comp.lang.prolog Subject: Re: 91 function Message-ID: <3832@milano.UUCP> Date: Tue, 17-Feb-87 18:21:17 EST Article-I.D.: milano.3832 Posted: Tue Feb 17 18:21:17 1987 Date-Received: Wed, 18-Feb-87 21:28:35 EST References: <3782@milano.UUCP> Sender: varghese@milano.UUCP Organization: MCC, Austin, TX Lines: 29 Summary: Typo in prolog version In article <3782@milano.UUCP>, varghese@milano.UUCP writes: > > A "fix" to make it converge to 91: > > (defun f91 (x) > (cond ((= x 91) 91) > ((> x 111) (f91 (f91 (- x 10)))) > ((> x 100) (f91 (- x 10))) > (t (f91 (f91 (+ x 11)))))) > > or, if you don't speak LISP, a Prolog version: > > f91(91,91) :- !. > f91(X,Y) :- X > 111, !, Z is X - 10, f91(Z,W), f91(W,Y). > f91(X,Y) :- X > 100, !, Z is X - 10, f91(Z,Y). > f91(X,Y) :- Z is X + 10, f91(Z,W), f91(W,Y). > The last line of the prolog version should be f91(X,Y) :- Z is X + 11, f91(Z,W), f91(W,Y). to make it correspond to the Lisp version. I work on Lisp machines and the Prolog version is a translation of the Lisp program. Sorry about that. -------------------- Joe Varghese varghese@mcc.com