next up previous
Next: Negation Up: prolog Previous: Lists in Prolog

Prolog Lispism

car([X|Y],X).

cdr([X|Y],Y).

cons(X,R,[X|R]).

means

The head (car) of [X|Y] is X.

The tail (cdr) of [X|Y] is Y.

Putting X at the head and Y as the tail constructs (cons) the list [X|R].