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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,c0581b94f07c034a,start X-Google-Attributes: gid103376,public From: kolc7797@PROBLEM_WITH_YOUR_MAIL_GATEWAY_FILE.nyu.edu (Fanni Kolchina) Subject: Constraint Error - Please Help Date: 1998/12/02 Message-ID: <7445iv$gog$1@news.nyu.edu>#1/1 X-Deja-AN: 417959941 X-Complaints-To: usenet@news.nyu.edu X-Trace: news.nyu.edu 912628127 17168 (None) 128.122.20.15 Organization: New York University Newsgroups: comp.lang.ada Date: 1998-12-02T00:00:00+00:00 List-Id: Hi, All: I am writing a generic sorting program in Ada using heap sort. I am new to Ada, and have no experience with this. When I run my program, I get a Constraint Error: range error. I have spent lots of time thinking what is wrong, but I just cannot comprehend it. If someone could help me, I will greatly appreciate it. Below is my code, and the line where the exception is thrown is marked by comment lines above and below it. Thanks a lot! with ada.text_io; use ada.text_io; with ada.integer_text_io; use ada.integer_text_io; with ada.float_text_io; use ada.float_text_io; procedure test_sort is generic type ITEM is private; type SORT_ARRAY is array(Positive range <>) of ITEM; with function "<" (u,v: ITEM) return boolean is <>; function sort_generic (x: SORT_ARRAY) return SORT_ARRAY; subtype index is positive range 1..10; type floatArray is array (positive range <>) of float; fa, hfa, shfa: floatArray(index); procedure printFloatArray (fa: floatArray) is begin for count in fa'first..fa'last loop put(fa(count), fore=>3, aft=>1, exp =>0); end loop; new_line; end; function sort_generic (x: SORT_ARRAY) return SORT_ARRAY is copy: SORT_ARRAY(x'range); last, left, right, max_l_r, current, this, parent: integer; end_node, contents : ITEM; begin for i in x'first..x'last loop copy(i):=x(i); end loop; for i in x'first+1..x'last loop this:=i; parent:= (i-1)/2; contents:=copy(this); ---------------------------------------------------------------- -- here's the line with the exception --- while this /= x'first and then copy(parent)last-1; -- if there is a left node then find whether left or -- right node (if any) is max_l_r right:=left+1; if right>last-1 or copy(right)