Webeks.net - freelance programming
freelance programming - php, Joomla, Zend ...
Home :: Articles :: Programming :: Prolog :: Prolog function - add member element to list

Prolog function - add member element to list

Written by Miha
%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).


blog comments powered by Disqus