Week 8 Flashcards

(6 cards)

1
Q

What is an Atom in Prolog?

A

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’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Is it possible to split atoms in Prolog?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are lists in Prolog?

A

Made up of elements (possibly of different type) enclosed in square brackets and separated by commas

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the Cons List notation in Prolog?

A

The cons (or “|”) notation allows one to create a list from the first few elements and the rest

[1,2,3|[4,5]]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is Pattern Matching in Prolog?

A

The cons (or “|”) notation allows one to pattern match against a list using variables for the first few elemtns and the rest

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly