3 ms·
As has already been mentioned, thats not a function, it is a functor. It indicates a relation between two objects. Specifically, it tells the prolog runtime tha
by newt0311 18y ago
As has already been mentioned, thats not a function, it is a functor. It indicates a relation between two objects. Specifically, it tells the prolog runtime that a list appended to an empty list is just the list itself and that the resultant list and the first list argument should have the same prefix. Another thing to note is that the append function piggy-backs on the prolog version of list-appended cons-cells so that append function example is a bit deceiving. However, the power of prolog should not overlooked. For example, a call to append(X, Y, [1, 2, 3]) would have returned all possible values of X and Y which append to [1, 2, 3]. Something much harder in other languages.
An extremely (imho) good source for information on logic programs and how they are implemented is here: http://www.ida.liu.se/~ulfni/lpp/ http://www.ida.liu.se/~ulfni/lpp/
A more practical guide to actually compiling these logic programs efficiently (or as efficient as they can be) is documented in Modern Compiler Design by Dick Grune et al. They actually describe the workings of a somewhat simplified workings of a Warren Abstract Machine (WAM) which can (to my knowledge) now approach to within an order of magnitude of standard programming languages. Pretty amazing when the generality of logic programming is considered. Details on the WAM here: http://en.wikipedia.org/wiki/Warren_Abstract_Machine http://en.wikipedia.org/wiki/Warren_Abstract_Machine