|
How to prepare
|
|
|
At a general level of list processing (rather than
specifically in Prolog), think about how you would:
- Append two lists to form a third, longer list, e.g:
[a,b,c], [1,2,3] → [a,b,c,1,2,3]
-
Delete one instance of a given term from a
list, e.g. delete a:
[a,b,c,a,b,c,a,b,c] → [b,c,a,b,c,a,b,c]
[a,b,c,a,b,c,a,b,c] → [a,b,c,b,c,a,b,c]
[a,b,c,a,b,c,a,b,c] → [a,b,c,a,b,c,b,c]
-
Delete either one or all instances of a given term from a list,
e.g. delete a:
[a,b,c,a,b,c,a,b,c] → [b,c,b,c,b,c]
Think about how, in Prolog, you could change the order in which
a given term was deleted from a list - so that the instance
deepest in the list is the first to be removed:
[a,b,c,a,b,c,a,b,c] → [a,b,c,a,b,c,b,c]
[a,b,c,a,b,c,a,b,c] → [a,b,c,b,c,a,b,c]
[a,b,c,a,b,c,a,b,c] → [b,c,a,b,c,a,b,c]
|
|