|
Lecture 9: Processing lists in Prolog 3
This lecture concentrates on accumulators - used to make
programs more efficient by cutting out unnecessary extra steps.
This lecture include:
- using accumulators to write more efficient (and especially
tail-recursive) procedures;
- writing list processing rules that are called from within
list processing rules;
- doing the "impossible" - adding to the end of a list;
- rewriting procedures to make them more efficient - by adding
extra arguments.
|
|
How to prepare
|
|
|
At a general level of list processing (rather than
specifically in Prolog), think about how you would:
- how you could copy a list, member by member:
- so the new list is in the same order as the old list
- so the new list is in the reverse order of the old list;
- given a list which is made up of a mixture of atomics or
lists (which are made up of a mixture of atomics or lists
(which are made up of a mixture of atomics or lists ( etc ))),
output each atomic in the order they occur in the list. So,
the list:
[[a,b],e,[[f]]]
would be output as:
a b e f
|
|
|
|
|
Slides
|
|
|
If you really want the slides from the lecture ...
but don't forget printing the slides is not the same as understanding them.
|
|
|
|
|
Programs from the lecture
|
|
|
|
|
|
Individual study suggestions and further reading
|
|
|
Amongst the less elementary topics on
lists
to be studied include:
Less elementary topics in list processing are covered in:
The best source on advanced list processing techniques (i.e.
beyond the scope of this lecture) is:
|
|
|
Assessed work associated with this lecture
|
|
|
Tutorial sheet 4
|
|