From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,f551137f17ab163f X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-05-04 10:03:11 PST Newsgroups: comp.lang.ada Path: newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!feed2.onemain.com!feed1.onemain.com!uunet!dca.uu.net!ash.uu.net!xyzzy!nntp From: Jeffrey Carter Subject: Re: sort function X-Nntp-Posting-Host: e246420.msc.az.boeing.com Content-Type: text/plain; charset=us-ascii Message-ID: <3AF2DD7F.6832E7D9@boeing.com> Sender: nntp@news.boeing.com (Boeing NNTP News Access) Content-Transfer-Encoding: 7bit Organization: The Boeing Company X-Accept-Language: en References: <3AF2A5F8.63668DBD@brighton.ac.uk> Mime-Version: 1.0 Date: Fri, 4 May 2001 16:49:03 GMT X-Mailer: Mozilla 4.5 [en]C-CCK-MCD Boeing Kit (WinNT; U) Xref: newsfeed.google.com comp.lang.ada:7167 Date: 2001-05-04T16:49:03+00:00 List-Id: sc297 wrote: > > help . ive written a sort funtion, but for the life of me i cant work > out what i have done wrong. help me ada people > > with ada.text_io, ada.integer_text_io; > use ada.text_io, ada.integer_text_io; You never use anything from these packages, so why with and use them? > > procedure sort( Data: in out Vector ) is Here you reference type Vector, which is undefined (a type declaration must occur before you can reference it). > Type Vector is array( Positive Range <> ) of Integer; Here you define type Vector, but it's too late. > > temp : integer:=0; > status : boolean := false; > swap:integer:=0; > Begin > while status /= true loop If you rewrite this as loop exit when Status; you can see that Status needs a better name, like Done or Finished. > For I in data'first..data'last-1 loop > If data(I)>data(I+1) then > temp:=data(I); > data(I):=data(I+1); > data(I+1):=temp; > swap:=swap+1; > Else > Null; > End if; > > If swap = 0 then > Status := true; > Else > Status:=false; > End if; This if can be replaced by Status := Swap = 0; which is clearer. > End loop; > swap:=0; > End loop; > End sort; It looks to me as if Swap is really a Boolean. You should ask John English about this. That's what he's there for. -- Jeffrey Carter