Path: csiph.com!1.us.feeder.erje.net!3.eu.feeder.erje.net!feeder.erje.net!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch
Newsgroups: comp.programming
Subject: Re: A little puzzle.
Date: Thu, 01 Dec 2022 04:30:45 -0800
Organization: A noiseless patient Spider
Lines: 40
Message-ID: <86wn7b5mru.fsf@linuxsc.com>
References: <875yf8nijb.fsf@bsb.me.uk> <865yf79l66.fsf@linuxsc.com> <87wn7nj9mb.fsf@bsb.me.uk> <86sfi98xnx.fsf@linuxsc.com> <87leo1i5bo.fsf@bsb.me.uk> <86k03k7yqe.fsf@linuxsc.com> <87o7stisxy.fsf@bsb.me.uk> <875yf1i26r.fsf@bsb.me.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader01.eternal-september.org; posting-host="67b01cddb462709762c0c460072e4ec7"; logging-data="2949833"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18zeD+5osdt+b+W8vagTQJXCAtgKDR4j2Q="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:qSKyu0cPu9kwR5Eh5L7OW3f41R8= sha1:mum6I080ghEBvsMSG0BHNBdznlk=
Xref: csiph.com comp.programming:16018
Ben Bacarisse writes:
> "Dmitry A. Kazakov" writes:
[...]
>> function Flight_East_Crosses_Longitude
>> ( Start, Stop, X : Longtitude
>> ) return Boolean is
>> begin
>> if Start <= Stop then
>> return X in Start..Stop;
>> else
>> return X <= Stop or else X >= Start;
>> end if;
>> end Flight_East_Crosses_Longitude;
>
> Except for some boundary cases [ie, the region being half open] that
> have got lost in the telling, this is similar to Tim's solution. I
> chose to use a recursive call, because I though it explained the
> non-trivial case more clearly (but I bet I am pretty much the only
> one who thinks that).
I want to add something here to my earlier comment. The idea of
using a recursive call reflects a deeper understanding of what
"circular regions" are. If one has already assimilated that
understanding then I think the recursive call is "more obvious",
in the sense that it takes less thought, or I might say less
additional thought. I didn't have that background (and didn't
develop it while solving the problem) so for me the cruder but
more direct approach was easier to see. Bottom line, I don't
think either formulation is uniformly "easier to understand" than
the other; it depends on one's background (or ability to develop
a suitable understanding on the fly, which in this case I did not
possess).
This problem provides an example where it helps to see both
approaches to solving the problem, to see how they relate to each
other, but also to give an appreciation for the power of having
more advanced tools available in the mental toolbox.