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-Thread: 103376,3f1374bc66d2dc03 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.scarlet.biz!news.scarlet.biz.POSTED!not-for-mail NNTP-Posting-Date: Tue, 14 Feb 2006 17:11:40 -0600 From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: creating an array References: <1139897171.996297.230070@z14g2000cwz.googlegroups.com> <1139951664.264622.240870@z14g2000cwz.googlegroups.com> <1139955455.397334.310790@g43g2000cwa.googlegroups.com> <878xsd8sqq.fsf@ludovic-brenta.org> <1139957691.430522.159580@o13g2000cwo.googlegroups.com> Date: Wed, 15 Feb 2006 00:10:42 +0100 Message-ID: <874q318rkd.fsf@ludovic-brenta.org> User-Agent: Gnus/5.110004 (No Gnus v0.4) Emacs/21.4 (gnu/linux) Cancel-Lock: sha1:th62FuhZPUAwkUj9hJATWm3tzC0= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii NNTP-Posting-Host: 83.134.238.224 X-Trace: sv3-nMM5GnT3D0P4Si1HV5ZnSFXSm2diRWgovUyYGIz3jTAamRanN+cuAGWENBC75E8AfPGRa5jtGY/sluw!BaXQXclrDxB2st4yfvePHutdFOPwljk9Hb9iVQbPokRG22Sk20Au8LFk66ZXF/vTPsdYMg79jVk= X-Complaints-To: abuse@scarlet.be X-DMCA-Complaints-To: abuse@scarlet.biz X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.32 Xref: g2news1.google.com comp.lang.ada:2898 Date: 2006-02-15T00:10:42+01:00 List-Id: "isaac2004" writes: >>If I understand the problem correctly, what you want is: > > Inputs: 4 and 1977 > Output: 1779 > > > that is sort of correct but the code you just gave me just puts the > array into a string and parses it out when the operation should be done > on the array, i see that you can do it that way but that would make > throw away all of my old code. how can the old code be changed, > especially the procedure to split the file, so that i can preform these > actions on an array No, my program does not "put the array into a string". It obtains user input as a string (which is its natural form anyway), transforms is into an array of Naturals, and then walks the array to display sorted digits. Your program takes the user input as a string (its natural form), converts it to a number (by means of Ada.Integer_Text_IO.Get), and then tries to massage it back into an array. This is not only convoluted, it is also inefficient. If that's any help, you can convert a number to an array by working backwards; units first, then tens, then hundreds etc. This should get you going: type Index_Type is range 0 .. 9; type Occurrences_Type is array (Index_Type) of Natural; procedure Split (Number : in Natural; Occurrences : out Occurrences_Type) is Occurrences := (others => 0); begin while Number > 0 loop Index := Index_Type (Number mod 10); Occurrences (Index) := Occurrences (Index) + 1; Number := Number / 10; end loop; end Split; But I still think my solution is much, much better :) -- Ludovic Brenta.