From goldkobi@barak-online.net Thu Aug 30 01:24:05 2001 Received: from storm.barak-online.net (host117.barak.net.il [212.150.48.117] (may be forged)) by swi.psy.uva.nl (8.11.2/8.11.2) with ESMTP id f7TNO5b11168 for ; Thu, 30 Aug 2001 01:24:05 +0200 (MET DST) Received: from kobigold ([10.10.11.13]) by storm.barak-online.net (InterMail vK.4.03.00.00 201-232-121 license 42798954b94fcb168b1407e1533853c1) with SMTP id <20010829232411.EPAB27332.storm@kobigold> for ; Thu, 30 Aug 2001 02:24:11 +0300 Message-ID: <001501c130ea$54dc78a0$507796d4@kobigold> From: "Kobi" To: Date: Thu, 30 Aug 2001 02:25:46 +0200 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0012_01C130FB.1341F9E0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Subject: [SWIPL] how sort works? This is a multi-part message in MIME format. ------=_NextPart_000_0012_01C130FB.1341F9E0 Content-Type: text/plain; charset="windows-1255" Content-Transfer-Encoding: quoted-printable Does somebody know how the function 'sort' works? from some reason whn I do listing(sort). It doesn't give me the way this function build. I know it should be something like insert_sort(List,Sorted):-i_sort(List,[],Sorted). i_sort([],Acc,Acc). i_sort([H|T],Acc,Sorted):-insert(H,Acc,NAcc),i_sort(T,NAcc,Sorted). =20 insert(X,[Y|T],[Y|NT]):-X>Y,insert(X,T,NT). insert(X,[Y|T],[X,Y|T]:-X=3D
Does somebody know how the function 'sort'=20 works?
from some reason whn I do = listing(sort).
It doesn't give me the way this function=20 build.
 
I know it should be something like
 
insert_sort(List,Sorted):-i_sort(List,[],Sorted).
i_sort([],Acc,Acc).
i_sort([H|T],Acc,Sorted):-insert(H,Acc,NAcc),i_sort(T,NAcc,Sorted).
  =20
insert(X,[Y|T],[Y|NT]):-X>Y,insert(X,T,NT).
insert(X,[Y|T],[X,Y|T]:-X=3D<Y.
insert(X,[],[X]).
But this is for =
numbers. anyway it doesn't what I need
I have to see how sort is.
thanks
------=_NextPart_000_0012_01C130FB.1341F9E0--