In interview style, here’s the conclusion of my reflections after studying Prolog for two months. If you’d like, read Part 1 first.
What did you find unique about the language?
Unification! Prolog works by trying to make terms equal one another. In most languages, the statement “Cost = 100” sets the variable “Cost” to a value of 100. In Prolog, “Cost = 100” means (in effect): “can Cost and 100 be unified?” During execution, Prolog takes into account the entire set of logical rules that have been defined to figure out if Cost and 100 are allowed to equal the same value. While possible, the need for statements manipulating variables’ values within an operation occurs far less frequently in Prolog than in the languages I’m used to. Continue reading
Reading my way through Seven Languages in Seven Weeks this past fall, Prolog caught my attention. The language worked so differently than any I’d used. It offered to solve problems challenging to code in the languages I was familiar with. Intrigued, I started setting aside an hour each workday to study Prolog. Learn Prolog Now! served as my primary tutorial. In interview-style, here are my thoughts after two months of exploring Prolog. Continue reading
Here’s a new word for me:
Arity—In a computer programming language, the number of arguments a function or operation accepts. For example, public void FindUser(string FirstName, string LastName) has an arity of two.
I discovered this word recently as I began exploring Prolog. In most programming languages I’ve worked with, the numerical value of an operation’s arity isn’t emphasized. In the Prolog world—in documentation, discussion and in the interpreter’s output— predicate names are always coupled with their arity. For example: reverseList(In, Out) is referred to as reverseList/2 (with the ”/2″ indicating an arity of two).
More Details on Arity