Week 8 Flashcards
(6 cards)
What is an Atom in Prolog?
A constant that does not have a numerical value. It begins with lowercase letter, or is quoted “”
The idea is to use lists of atoms instead of concatenated strings
eg.
Buffalo
malcolmX
‘The X Files’
Is it possible to split atoms in Prolog?
It is possible (but difficult) to split atoms into lists of ASCII codes, and to make atoms from lists of ASCII codes
eg.
ace -> [97,99,101] (ASCII digits)
[97,99,101] -> ace
What are lists in Prolog?
Made up of elements (possibly of different type) enclosed in square brackets and separated by commas
What is the Cons List notation in Prolog?
The cons (or “|”) notation allows one to create a list from the first few elements and the rest
[1,2,3|[4,5]]
What is Pattern Matching in Prolog?
The cons (or “|”) notation allows one to pattern match against a list using variables for the first few elemtns and the rest