Home My formal education Article list Prolog Prolog reverse list function

Prolog reverse list function

E-mail Print
Share/Save/Bookmark
%reverse(List,RList).
%example use reverse([a,b,c,d],R).
%R = [d,c,b,a] ? ;

reverse([],[]).
reverse([X|R],Reversed):-
reverse(R, RevRest),
conc(RevRest,[X],Reversed).
Hits: 8532
Comments (1)Add Comment
April 18, 2009     
Thanks (=
I think that Easy than above Right (;

Rev(L,L1) :- Conc(L,[ ],L1).
Conc( [X|T] , L2 ,L3) :- Conc( T,[X|L2],L3).


Thanx agin

KOZA
KOZA | 78.93.86.12

Write comment

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

Donate

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