How Do You Create A Prolog Append Predicate?
Prolog contains a built-in predicate called “append” that appends two lists, but writing your own will help you gain an understanding how the language uses matching and unification to perform computations. In a procedural and imperative programming language (such as C++ or Java), you would write an algorithm that loops over two lists and appends them together. In Prolog, you do the opposite; you write a set of rules that define what the final list should look like, and the interpreter applies those rules to compute the result. Like the built-in “append” predicate, you will define an “appendLists” predicate that takes three arguments: the first list, the second list, and the result of appending the first and second lists together. In Prolog, empty square brackets “[]” (without quotes) denotes the empty list, and the notation “[First | Rest]” (without quotes) represents a list whose first element is “First” and whose remaining elements are a list called “Rest”. Define a rule for the base