[comp.lang.prolog] nice prolog code

bimandre@icarus.cs.kuleuven.ac.be (Andre Marien) (01/30/91)

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