The follow is a continuation of the previous posting “Prolog using Examples – Part 4” Example 1: Check the prefix of a list. /* Base case */ /* When the list of prefix checked is empty means that we stop checking */ prefix([],_). /* Recursive case */ /* Both head of the list must be […]
Posts with the lists tag
Prolog using examples – Part 4
In this part of this practical tutorial, we are going to do some coding involving facts, rules, recursion, and lists. Example 1: Obtain the head of the list, obtain the tail of the list. /* Get the head of the list */ get_head(Head, [Head|_]). /* Get the tail of the list */ get_tail(Tail, [_|Tail]). ?- […]