Types of Prolog
Prolog is used to provide the Tuples, lists, numbers, atoms, and patterns. In this section, we can define the type of objects that are passed as arguments.
This type of Prolog is implementation-dependent. The following table shows the implementation of a simple type of prolog:
The Boolean constants are not passed as an argument. Variables describe the character string. The character strings start with a capital letter or upper case letter. Atoms are constants that have no numerical value. All the atoms start with a lower case letter or small letter.
The distinction between data and program are blurred in prolog. In the argument, data is often passed to predicates. In prolog, the most common data structure is lists. Lists are much like the stack in which we can only sequentially access the lists of elements, and much like the array in which we have a list of elements sequentially.
Prolog is used to allow arbitrary patterns as data, and that pattern represents tuples. An array is not provided by Prolog. But single or multidimensional arrays may be represented as a list or list of lists. The array can also be represented by a set of facts in the database.
TYPE REPRESENTATION [ comma separated sequence of items ] list pattern sequence of items
Using the square brackets (+), a prolog list can represent. The following example shows a list of fruits:
[mango, grapes, orange]
The above list shows the elements mango, grapes, and orange. In prolog list, the elements are ordered. If there are no indexes, the elements will also be ordered. Using the patterns, the tuples can be represented.
Using the pattern matching, the elements of tuples can be accessed.
The user has to determine the parameter type because prolog is a weakly typed language. To determine the parameter type in prolog, the following built-in predicate can be used.
In the above example, T =..L, function(T,F,A), and clause(H,T) are used in program manipulation.
clause(H,T): It checks the database content.
The following example shows the predicate function:
T is a term, F is its functor, and A is its arity.
t: It is the function of the term