From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=0.8 required=3.0 tests=BAYES_50 autolearn=ham autolearn_force=no version=3.4.5-pre1 X-Received: by 2002:a0c:b181:: with SMTP id v1mr17234983qvd.36.1607711042049; Fri, 11 Dec 2020 10:24:02 -0800 (PST) X-Received: by 2002:ac8:41cf:: with SMTP id o15mr17123495qtm.98.1607711041878; Fri, 11 Dec 2020 10:24:01 -0800 (PST) Path: eternal-september.org!reader02.eternal-september.org!aioe.org!peer03.ams4!peer.am4.highwinds-media.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 11 Dec 2020 10:24:01 -0800 (PST) In-Reply-To: <86mtykp8yd.fsf@stephe-leake.org> Complaints-To: groups-abuse@google.com Injection-Info: google-groups.googlegroups.com; posting-host=2601:3c3:401:f550:b18c:ac97:6d51:fa4c; posting-account=JSxOkAoAAADa00TJoz2WZ_46XrZCdXeS NNTP-Posting-Host: 2601:3c3:401:f550:b18c:ac97:6d51:fa4c References: <86mtykp8yd.fsf@stephe-leake.org> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: advent of code day 11 From: John Perry Injection-Date: Fri, 11 Dec 2020 18:24:02 +0000 Content-Type: text/plain; charset="UTF-8" X-Received-Bytes: 2724 Xref: reader02.eternal-september.org comp.lang.ada:60803 List-Id: On Friday, December 11, 2020 at 11:08:00 AM UTC-6, Stephen Leake wrote: > mildly interesting; variation on Conway's Game of Life. I recognized that, too. A solution should not be hard to parallelize, and I'd like to, but for now I have other tasks. (no pun intended, well, OK yes it was) Here's a couple of questions for the Ada experts. For each round I used two charts, a source and a result. These are arrays, defined like so: type Status is ( Floor, Empty, Occupied ); type Chart_Array is array( Positive range <> , Positive range <> ) of Status; Chart1, Chart2: Chart_Array; -- actually defined with appropriate dimensions A procedure named `Iterate_Seating` applies the given rules to a Chart_Array; an `if` statement determines which iterates into the other. I thought it would be clearer to use references to switch from one chart to the other, but I had trouble doing that last night. Now I can get it this way: Source: Chart_Array renames Chart1; Result: Chart_Array renames Chart2; while Changed loop Perform_Round( Source => Source , Result => Result , ... ); declare Tmp: Chart_Array renames Source; begin Source := Result; Result := Tmp; end; end loop; Does this technique swap references, or does it copy the arrays element-by-element? The run times are the same even if I compel a copy operation; I suppose it's because the arrays aren't large enough, and there aren't enough copies, to make a difference. thanks john perry