next up previous
Next: Using Conc for more Up: No Title Previous: Recursive Arithmetic

Back to Lists

Membership again :

member(X, [X | _]).
member(X, [ _| Tail]) :-
	member(X, Tail).

Concatenating Lists (combining two lists together into one) :

conc( [], L, L).

conc( [X | L1], L2, [ X|L3 ]) :-
 conc(L1, L2, L3).

Issuing the command :

conc( [1,2], [3,4], [1,2,3,4])
will return yes

Similarly, a query :

conc( [1,2], [3,4], L)
will return L = [1,2,3,4]


next up previous
Next: Using Conc for more Up: No Title Previous: Recursive Arithmetic

Omer F Rana
Fri Feb 14 20:23:31 GMT 1997