Defining Predicates on Lists
car([X|L], X).
cdr([X|L], L).
cons(X, L, [X|L]).
?- car([a, b, c], X).
X = a
?- cdr([a, b, c], X).
X = [b, c]
?- cons(a, [b, c], X).
X = [a, b, c]
Previous slide
Next slide
Back to first slide
View graphic version