comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: String literals and wide_string literals - how?
Date: Fri, 20 Apr 2007 22:41:35 +0200
Date: 2007-04-20T22:40:24+02:00	[thread overview]
Message-ID: <ra78ml24abuc.wtzenxqfdc1j.dlg@40tude.net> (raw)
In-Reply-To: 1177099260.665252.323030@l77g2000hsb.googlegroups.com

On 20 Apr 2007 13:01:00 -0700, Adam Beneschan wrote:

> On Apr 20, 12:16 pm, "Randy Brukardt" <r...@rrsoftware.com> wrote:
> 
>> Now throw in some operator overloading:
>>
>>     function "+" (Left, Right : Roman_Numeral) return Roman_Numeral;
>>
>> and you can work solely in Roman_Numerals.
> 
> It would be an interesting challenge to write this function---without
> cheating.  That is, without resorting to converting the operands to
> regular integers, adding them the normal way, and converting the
> result back.  No, no, no.  Do it the way the Romans would have had to
> do it.  Might make for a good programming exercise.

Not that hard, Ada has loop in reverse. I think that for summation, even
one character look-ahead is not actually needed (for IV, IX, XL etc stuff).
One should postpone flushing the last "decimal" place before recognizing
the next one, so that gone astray I, X, C could be subtracted from it.

> And then, if someone gets this right, tell them to implement "*".

Romans used abacus for that, they cheated! (:-))

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  reply	other threads:[~2007-04-20 20:41 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-20 10:07 String literals and wide_string literals - how? Gerd
2007-04-20 14:33 ` Adam Beneschan
2007-04-20 14:55 ` Robert A Duff
2007-04-20 19:16   ` Randy Brukardt
2007-04-20 20:01     ` Adam Beneschan
2007-04-20 20:41       ` Dmitry A. Kazakov [this message]
2007-04-20 20:02     ` Robert A Duff
2007-05-21  2:33       ` David Thompson
2007-05-22 22:32         ` Randy Brukardt
2007-05-23 18:42           ` Jeffrey R. Carter
     [not found]             ` <f324h5$fna$1@f04n12.cac.psu.edu>
2007-05-24 21:15               ` Jeffrey R. Carter
2007-05-23  2:27         ` Keith Thompson
2007-07-01  1:00           ` David Thompson
2007-05-23 12:28         ` brian.b.mcguinness
2007-04-20 20:48     ` Dmitry A. Kazakov
2007-04-20 22:09   ` Jeffrey R. Carter
2007-04-21  9:41     ` Simon Wright
2007-04-22  0:35       ` Jeffrey R. Carter
2007-04-22  9:45         ` Simon Wright
2007-04-22 20:15           ` Jeffrey R. Carter
2007-04-22 21:18             ` Simon Wright
2007-04-23  1:44               ` Jeffrey R. Carter
2007-04-22  1:00     ` Robert A Duff
2007-04-20 14:58 ` Georg Bauhaus
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox