Prolog recursion: family trees and lists
9 steps · about 3 h 25 min · Beginner
- Prolog By Example: 7 - Introducing Recursion (blog, Prolog By Example, 15 min)
It introduces the base case and recursive case with a small ancestor example and search-tree diagrams.
- Prolog Tutorial - Recursion (tutorial, Goldsmiths, University of London, 15 min)
It traces ancestor(john,tom) step by step, so you see how Prolog matches clauses and backtracks.
- How to learn Prolog by watching Game of Thrones (tutorial, freeCodeCamp, 20 min)
It builds parent, sibling and ancestor rules on a familiar tree and adds findall to collect all the answers.
- Prolog Programming: a do-it-yourself course for beginners (tutorial, Union College (Striegnitz), 30 min)
You write ancestor_of/2 yourself and test it with questions about Harry, Albert and Dudley.
- cs380 Prolog: recursive relations (doc, Radford University, 40 min)
Its exercises (grandfather, cousin, nth-cousin) stretch your recursion beyond the basic ancestor rule.
- Prolog Tutorial - Lists (tutorial, Goldsmiths, University of London, 20 min)
It moves from trees to lists by building append/3 through [Head|Tail] construction and deconstruction.
- 2.1 Recursion and lists (doc, University of York, 30 min)
It explains base and recursive clauses for member and append, and sets reverse/2 as an exercise.
- Prolog Language Tutorial => Recursion (article, RIP Tutorial, 15 min)
It reads append/3 declaratively, so you see why one definition can both check and generate lists.
- Prolog/Lists (reference, Wikibooks, 20 min)
It finishes with practical uses of append, such as last/2 and split, plus a note on efficiency.