Southern Man

Friday, November 06, 2009

Best Prolog Program EVER

As part of a few lectures on Prolog (an obscure but interesting logic-based programming language) Southern Man assigned his students to download SWI-Prolog and write a simple program. One submitted this gem. You don't have to be a computer science geek to appreciate it.
witch(X) :- burns(X), female(X).
burns(X) :- madeOfWood(X).
madeOfWood(X) :- floats(X).
floats(X) :- sameWeight(duck, X).

female(girl).
sameWeight(duck, girl).

-? witch(girl)

true
It's a fair cop...

0 Comments:

Post a Comment

<< Home