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 <prolog@swi.psy.uva.nl>; 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 <prolog@swi.psy.uva.nl>; Thu, 30 Aug 2001 02:24:11 +0300
Message-ID: <001501c130ea$54dc78a0$507796d4@kobigold>
From: "Kobi" <goldkobi@barak-online.net>
To: <prolog@swi.psy.uva.nl>
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<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
Content-Type: text/html;
	charset="windows-1255"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dwindows-1255">
<META content=3D"MSHTML 5.50.4134.600" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial>Does somebody know how the function 'sort'=20
works?</FONT></DIV>
<DIV><FONT face=3DArial>from some reason whn I do =
listing(sort).</FONT></DIV>
<DIV><FONT face=3DArial>It doesn't give me the way this function=20
build.</FONT></DIV>
<DIV><FONT face=3DArial></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial>I know it should be something like</FONT></DIV>
<DIV><FONT face=3DArial></FONT>&nbsp;</DIV>
<DIV><PRE><FONT =
size=3D2>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&gt;Y,insert(X,T,NT).
insert(X,[Y|T],[X,Y|T]:-X=3D&lt;Y.
insert(X,[],[X]).</FONT></PRE><PRE><FONT face=3DArial>But this is for =
numbers. anyway it doesn't what I need</FONT></PRE><PRE><FONT =
face=3DArial>I have to see how sort is.</FONT></PRE><PRE><FONT =
face=3DArial>thanks</FONT></PRE></DIV></BODY></HTML>

------=_NextPart_000_0012_01C130FB.1341F9E0--

