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,7728b533f7ab5fb6 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news.glorb.com!feeder.erje.net!news.germany.com!newsfeed1.funet.fi!newsfeeds.funet.fi!nntp.inet.fi!central1.inet.fi!inet.fi!read4.inet.fi.POSTED!53ab2750!not-for-mail Sender: AWI003@FIW9752 Newsgroups: comp.lang.ada Subject: Re: Avoiding side effects References: From: Anders Wirzenius Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Mon, 06 Oct 2008 12:09:42 GMT NNTP-Posting-Host: 194.251.142.2 X-Complaints-To: abuse@inet.fi X-Trace: read4.inet.fi 1223294982 194.251.142.2 (Mon, 06 Oct 2008 15:09:42 EEST) NNTP-Posting-Date: Mon, 06 Oct 2008 15:09:42 EEST Organization: Sonera Customer Xref: g2news1.google.com comp.lang.ada:2250 Date: 2008-10-06T12:09:42+00:00 List-Id: Ole-Hjalmar Kristensen writes: > If I understand your problem correctly, why not simply do the > following after the sort -u stage?: > > comm -23 fileA fileB Oops. I was not aware of that program. Looks promising. Thanks. > > But to answer the Ada quiestion, I think I would organize the loop a > little bit differently. The following is a classical way of merging > two files, but it should work in your case too: > > while not End_Of_File(File_A) and not End_Of_File(File_B) loop > -- Process records from both files > end loop; > > while not End_Of_File(File_A) loop > -- Process tail of file A > end loop; > > while not End_Of_File(File_B) loop > -- Process tail of file B > end loop; Thanks for that, too. The program I wrote did the job and was sufficiently fast. My question was more about how to do it using subprograms (functions) without side effects. I suppose "Process records from..." and "Process tail..." are having side effects if coded as subprograms, as they advance the pointer in the two files. -- Anders