Home My formal education Article list Prolog prolog add custom function

prolog add custom function

E-mail Print
Share/Save/Bookmark
%add(X,L,L1).
%adds element X to the beginning of the list L and returns L1
add(X,L,[X|L]).

%add(X,L,L1)
%adds element X to the end of the list L and returns L1
add(X,[],[X]).
add(X,[A|L],[A|L1]):-
add(X,L,L1).
Hits: 2551
Comments (0)Add Comment

Write comment

busy
Last Updated ( Wednesday, 27 August 2008 13:11 )  

Donate

Do you find content useful? Please donate so I can cover my hosting expenses! Thanks!