Newsgroups: comp.lang.prolog
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!oitnews.harvard.edu!fas-news.harvard.edu!newspump.wustl.edu!news.ecn.bgu.edu!vixen.cso.uiuc.edu!news.uoregon.edu!usenet.eel.ufl.edu!news.mathworks.com!news.kei.com!simtel!harbinger.cc.monash.edu.au!yarrina.connect.com.au!labtam!news.mel.aone.net.au!inferno.mpx.com.au!news.unimelb.EDU.AU!cs.mu.OZ.AU!munta.cs.mu.OZ.AU!fjh
From: fjh@munta.cs.mu.OZ.AU (Fergus Henderson)
Subject: Re: Question on strange behavior
Message-ID: <9524300.22493@mulga.cs.mu.OZ.AU>
Sender: news@cs.mu.OZ.AU (CS-Usenet)
Organization: Computer Science, University of Melbourne, Australia
References: <4164k5$f8d@gap.cco.caltech.edu> <419elf$ib0@osiris.wu-wien.ac.at>
Date: Wed, 30 Aug 1995 14:48:43 GMT
Lines: 34

fhoer <franz.hoermann@wu-wien.ac.at> writes:

>	rplus(A,B,Result) :-
>		A = zero,
>		B = Result.
>
>	rplus(A,B,Result) :-
>		bound(A),
>		A \= zero,
>		rsucc(Adown,A),
>		rsucc(Resultdown,Result),
>		rplus(Adown,B,Resultdown).
>		
>	rplus(A,B,Result) :-
>		free(A),
>		rplus(B,A,Result).

That solves the original problem, but introduces a new one!
Try the query `?- rplus(X, Y, four).'.
[BTW, didn't you mean `var(A)' rather than `free(A)'?]

The original post was a good example of how Prolog's non-logical
negation makes the language more difficult to learn.
Franz Hoermann's code is a good example of how Prolog's non-logical
features encourage people to write non-logical code that can be
difficult to understand and is often unreliable or buggy, particularly
when a predicate is called in a different mode to the (usually
undocumented) one that the predicate's author expected.

-- 
Fergus Henderson             |  #define x t=a[i],a[i]=a[m],a[m]=t
                             |  char a[]=" 12345678";main(m,i,j,t){for(i=m;i<
fjh@cs.mu.oz.au              |  9;x,i++)for(x,j=m;--j?(t=a[m-j]-a[m])-j&&t+j:
http://www.cs.mu.oz.au/~fjh  |  main(m+1)*0;);m-9||puts(a+1);} /* 8 queens */
