Delete element 2

Description

Deleting elements from a list

Source: The Art of Prolog

Download

Program source code: delete_element_2.pl

Listing

/*
   delete(Xs,X,Ys) :- 
	Ys is the result of deleting all occurrences of X from the list Xs.
*/
     delete([X|Xs],X,Ys) :- !, delete(Xs,X,Ys).
     delete([X|Xs],Z,[X|Ys]) :- Y \== X, !, delete(Xs,Z,Ys).
     delete([],X,[]).
 
%   Program 11.9a   Deleting elements from a list

Comments

pl/prolog/pllib/delete_element_2.txt · ostatnio zmienione: 2017/07/17 08:08 (edycja zewnętrzna)
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0