novice at prolog- need help with quicksort
- From: John Nankivell <Jrobin@xxxxxxxxxxx>
- Date: Mon, 29 May 2006 00:31:34 +0930
Hello
recently I have been introduced to prolog at my university. Our assignment entails us benchmarking quicksort in different languages, including prolog. Our lecturer gave us a hint not to use append within prolog. I have came across a version of this but it will not work because GNU doesn't have the built in predicates for not(X) and order(x,y). Could you please help? an example would be fantatic.
Here is the version of quicksort I have came across.
split(H,[A|X],[A|Y],Z):- order(A,H),split(H,X,Y,Z).
split(H,[A|X],Y,[A|Z]):- not(order(A,H)), split(H,X,Y,Z).
split(_,[],[]).
quicksort([],X,X).
quicksort([H|T],S,X):-split(H,T,A,B),quicksort(A,S,[H|Y]), quicksort(B,Y,X).
Thanks
-JOhn
.
- Follow-Ups:
- Re: novice at prolog- need help with quicksort
- From: Andreas Kochenburger
- Re: novice at prolog- need help with quicksort
- Prev by Date: Re: Logic Problems
- Next by Date: assigning constant to variable
- Previous by thread: tell listing failure in GNU prolog
- Next by thread: Re: novice at prolog- need help with quicksort
- Index(es):
Relevant Pages
|
|