Thus far, most of the lessons on this site have been about equations, mathematical operations, and numbers. We made the computer crunch numbers. It turns out, there's a lot to learn about coding that involves processing symbols (names, places, words, etc.). It's an odd thing to do with computers, that often gives surprising results that may give you hint of Artificial intelligence (or AI).
In this series of lessons, we'll stop with the Lua language, and use a language called Prolog to do some symbolic processing. Prolog is a very different and unique language that has a bit of the AI "wow factor" in what it can do (and how we code using it).
To start, Prolog is a very expressive language. You kind of make up the language yourself, as you need, almost like the way you think of words you need when you write a story. You are not bound to using for and if statements, and the like as you did in Lua.
In this example, let's use Prolog to express some facts about some things a person called "Tom" likes. Then we'll use Prolog to tell us what Tom likes.
likes(tom,thing). goal: likes(tom,X).
Move the mouse over a dotted box for more information.
Be sure all of your ideas and words are in all lower case. Only variables start with an upper-case letter. You can express as many such "facts" as you wish. Put each one on a line by itself.
Now you try. Certainly run this code, but also try to put in your own name and things you like.
Type your code here:
See your results here:
Go ahead and run this code as is and see what Prolog will do. When done, change the name tom to something else, perhaps your name. Also change things you like.
Other goals to try:
likes(tom,cookies). likes(tom,apples). likes(Person,rockets). likes(lily,rockets).
Share your code
Show a friend, family member, or teacher what you've done!