Ch2_1 CS3032
Ch2_1 CS3032
CS 3032
2
Introduction to Lists
3
• Prolog list structure for some elements such as { a, b, c, d, e, f } can be written as :
[ a, b, c, d, e, f ]
• Direct access is only to the first element in the list called, Head, while rest forms
the list Tail.
[ Head | Tail ]
Partition Symbol
Lists in Prolog: Example
/* The part which is considered before the
vertical bar (|), inside the square brackets is
the head of given list elements
9
Basic Programs in Lists: Example 2
12