I am tackling a third language from the book today. This is Prolog and we are not complete strangers. I remember using it at uni for some lab practices and I can remember we didn’t get along like a house on fire. I found Prolog strange and at odds with imperative mindset I held back then. Now that I am a bit older, I find the fact that language is a bit different appealing and intriguing and I look forward to see why was it designed in such manner and what benefits it’s approach brings.
Day 1 explains the very basic concepts behind the language. It explains its syntax which is very simple. Main constructs are atoms, variables, facts and rules.
%atoms me. brother. mother. granddad. %facts parent(me, mother). parent(brother, mother). parent(mother, granddad). %rules grandparent(X, Y) :- parent(X, Z), parent(Z, Y). sibling(X, Y) :- \+(X = Y), parent(X, Z), parent(Y, Z). % X, Y and Z are variables
No syntax highlighting is available – I guess that the “hip crowd” does not grok Prolog. Read on »