We now deal with a very common task: taking a list of elements and transforming each element into a new element (this can be seen as a mapping). The schema for this is:
process_all( Info,,).The reading for this is that the result of transforming all the elements in the empty list is the empty list otherwise, transform the head of the list and then transform the rest of the list.
where process_one/1 takes Info and H1 as input and outputs H2
The second clause can be rewritten to:process_all( Info,[H1T1],Ans):-Understanding the way in which this program works is quite difficult.
Ans = [H2T2].
An example program is one that takes a list of integers and `triples' each of them. The goal triple([1,12,7],X would result in X=[3,36,21]. We assume the mode of mode triple(+,-).
triple(,).This has the reading that the two arguments lie in the relation that the head of the second argument is 3 times that of the head of the first argument and the tails lie in the same relation. The declarative reading is easier to construct than exploring the way in which a goal is executed.
H2 is 3*H1,