Update: regrettably, I forgot to include Cookbook.pm in the manifest. 0.732 is now on its way.
AI::Prolog 0.73 is now on its way to a CPAN mirror near you.
Once again, we have a release I'm quite excited about. There's been a lot of work to clean up the output to make it easier to understand. For example, in previous versions, run the aiprolog shell and consult a file containing the following Prolog code:
append([W|X], Y, [W|Z])
Then, in the shell, type "listing.". You should get output similar to this:
That's really ugly. The
append(, A, A).
append([A|B], C, [A|D])
append(B, C, D).
That's much easier to read.
However, that's not the good stuff. I've now included the AI::Prolog::Cookbook. This document only has a few "recipes", but it does provide a few Prolog solutions of common problems. Here's a Prolog implementation of the quicksort algorithm:
This definition depends on the
append/3predicates defined in this document.
partition(Head, Tail, LHS, RHS),
append(Temp1, [Head|Temp2], Sorted).
Note that (currently) this will only sort numeric values.
The cookbook presents many recipes "as is". Other recipes have moderately extensive discussions about important caveats related to them. For example, there's a comparison of the "reverse accumulate" algorithm which runs in O(n) time and the "Naive reverse" algorithm which runs in O(n^2) time.