Lists Lists
York University CSE 3401 Vida Movahedi
York University‐ CSE 3401‐ V. Movahedi
1
05_Lists
Lists Lists York University CSE 3401 Vida Movahedi 1 York - - PowerPoint PPT Presentation
Lists Lists York University CSE 3401 Vida Movahedi 1 York University CSE 3401 V. Movahedi 05_Lists Overview Overview Definition and representation of Lists in Prolog Definition and representation of Lists in Prolog Dot functor
York University‐ CSE 3401‐ V. Movahedi
1
05_Lists
York University‐ CSE 3401‐ V. Movahedi
2
05_Lists
York University‐ CSE 3401‐ V. Movahedi
3
05_Lists
York University‐ CSE 3401‐ V. Movahedi
4
05_Lists
York University‐ CSE 3401‐ V. Movahedi
5
05_Lists
York University‐ CSE 3401‐ V. Movahedi
6
05_Lists
York University‐ CSE 3401‐ V. Movahedi
7
05_Lists
York University‐ CSE 3401‐ V. Movahedi
8
05_Lists
Example: append([1,2], [3,4], [1,2,3,4]) append([], L, L). : boundary condition append([X|L1], L2, [X|L3]) :‐ append(L1, L2, L3). : recursive case a smaller problem
[Nilsson] :‐ append([a, b], [c, d], [a, b, c, d]). true :‐ append([a, b], [c, d], X). X=[a, b, c, d]
:‐ append(Y, Z, [a, b, c, d]).
York University‐ CSE 3401‐ V. Movahedi
9
05_Lists
append([], X, X). append([X|Y], Z, [X|W]) :‐ append(Y, Z, W).
York University‐ CSE 3401‐ V. Movahedi
10
05_Lists
What is missing in definition of multiple(..)? How can it be corrected?
York University‐ CSE 3401‐ V. Movahedi
11
05_Lists
York University‐ CSE 3401‐ V. Movahedi
12
05_Lists
York University‐ CSE 3401‐ V. Movahedi
13
05_Lists
York University‐ CSE 3401‐ V. Movahedi
14
05_Lists
York University‐ CSE 3401‐ V. Movahedi
15
05_Lists