Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!lll-winken!uunet!mcsun!ub4b!kulcs!icarus.cs.kuleuven.ac.be From: bimandre@icarus.cs.kuleuven.ac.be (Andre Marien) Newsgroups: comp.lang.prolog Subject: nice prolog code Message-ID: <1642@n-kulcs.cs.kuleuven.ac.be> Date: 30 Jan 91 12:45:33 GMT Sender: news@cs.kuleuven.ac.be Organization: Dept. of Computer Science (K.U.Leuven) Lines: 23 Originator: bimandre@icarus Recently, I saw a nice piece of code in a program used to benchmark prolog systems. I am not going to copy it here, just give a similar piece of code. (no, this is not about benchmarks, although that would be interesting) (no, this is not artificially created) p(T) :- T =.. [F|AL], length(AL,AR), q(F/AR,AL,R) . q(+/2,[X,Y],R) :- R is X + Y . q(+/1,[R],R) . q(*/2,[X,Y],R) :- R is X * Y . (I may have the order of the arguments to length wrong; the reason I found this beauty was that I was curious what length/2 was used for) As long as people use prolog this way when they try it out (which was NOT the case for the programer who wrote this, I am afraid) prolog has no chance of being accepted by the rest of computer science. Suggestions for remedies are invited. Andre' Marien bimandre@cs.kuleuven.ac.be