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=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.66.87.99 with SMTP id w3mr4471028paz.12.1474819616626; Sun, 25 Sep 2016 09:06:56 -0700 (PDT) X-Received: by 10.157.55.181 with SMTP id x50mr1238960otb.7.1474819616575; Sun, 25 Sep 2016 09:06:56 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.glorb.com!x192no4443710itb.0!news-out.google.com!b4ni12100iti.0!nntp.google.com!u18no4313514ita.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sun, 25 Sep 2016 09:06:56 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=76.218.37.33; posting-account=W2gdXQoAAADxIuhBWhPFjUps3wUp4RhQ NNTP-Posting-Host: 76.218.37.33 References: <955937c4-b9f9-4e21-9d22-98382df2f45f@googlegroups.com> <0e690fe0-7ac8-4843-8792-50ae14729bcc@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: New to Ada need help implementing Warshall's algorithm From: Stephen Leake Injection-Date: Sun, 25 Sep 2016 16:06:56 +0000 Content-Type: text/plain; charset=UTF-8 Xref: news.eternal-september.org comp.lang.ada:31888 Date: 2016-09-25T09:06:56-07:00 List-Id: On Friday, September 23, 2016 at 10:07:53 AM UTC-5, James Brewer wrote: > > It is three diffent sets of data. I think I may try to simplify the input data to a 0,1 2d array for each set, read the set in and then process each set writing it to an output file (the last two I will have to figure out). Here's a working program that does the IO, to get you started. It reads from a file, writes to standard out. Reading the entire input line from the file, then processing it, simplifies debugging. with Ada.Command_Line; with Ada.Text_IO; use Ada.Text_IO; procedure Warshall is procedure Put_Usage is begin Put_Line ("Usage: warshall "); end Put_Usage; File : File_Type; begin Open (File, In_File, Ada.Command_Line.Argument (1)); loop exit when End_Of_File (File); declare Line : constant String := Get_Line (File); -- Each line should have format 'A B' where, A, B => 1 | 0 A : Boolean; B : Boolean; begin if Line (1) = '0' then A := False; else A := True; end if; if Line (3) = '0' then B := False; else B := True; end if; -- FIXME: implement warshall's algorithm Put_Line ("A, B: " & Boolean'Image (A) & " " & Boolean'Image (B)); end; end loop; end Warshall; given an input file: 0 1 1 0 this produces: A, B: FALSE TRUE A, B: TRUE FALSE I'm happy to hear about an instructor using Ada to teach algorithms! -- Stephe