Reverse difference

Description

Reverse with difference-lists.

Source: The Art of Prolog

Download

Program source code: reverse_difference.pl

Listing

/*	
   reverse(Xs,Ys) :- Ys is the reversal of the list Xs.
*/
	:- op(40,xfx,\).
 
	reverse(Xs,Ys) :- reverse_dl(Xs,Ys\[]).
 
	reverse_dl([X|Xs],Ys\Zs) :-
		reverse_dl(Xs,Ys\[X|Zs]).
	reverse_dl([],Xs\Xs).
 
 
%	Program 15.3: Reverse with difference-lists.

Comments

pl/prolog/pllib/reverse_difference.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