experchange > linux.misc

Andreas Kohlbach (02-28-20, 04:17 PM)
Just watched an interesting Youtube episode of Computerphile. One
professor doing lectures on regular expression and shows if it works on
UNIX, being a UNIX guy since the 1970s. He came up with the expression
^I[XV]|V?I{0-3}$ which works with Roman numerals up to 9. In a future
episode he wants to cover to get the rest (L, M, C) into *one* beautiful
regex.

Thought some of you here would apprecate
it. <https://www.youtube.com/watch?v=M3x5Z3iIoSU> runs 17 minutes.
Allodoxaphobia (02-28-20, 10:16 PM)
On Fri, 28 Feb 2020 09:17:34 -0500, Andreas Kohlbach wrote:
> Just watched an interesting Youtube episode of Computerphile. One
> professor doing lectures on regular expression and shows if it works on
> UNIX, being a UNIX guy since the 1970s. He came up with the expression
> ^I[XV]|V?I{0-3}$ which works with Roman numerals up to 9. In a future
> episode he wants to cover to get the rest (L, M, C) into *one* beautiful
> regex.
> Thought some of you here would apprecate
> it. <https://www.youtube.com/watch?v=M3x5Z3iIoSU> runs 17 minutes.


Several hundred years ago, as an Adjunct Professor, I had my Intro
Programming classes write a program to do base number conversions --
from base 10 to base 2, base 8 and base 16.
Extra Credit was to also convert to Roman Numerals.

That last really separated the Thinkers from the non-thinkers.

(Of course, sadly, many had no knowledge of Roman Numerals.)

Jonesy
Jack Strangio (02-29-20, 04:44 AM)
Allodoxaphobia <trepidation> writes:
> (Of course, sadly, many had no knowledge of Roman Numerals.)
> Jonesy


Most peoples' exposure to Roman Numeral comes from the copyright dates shown
on various movies and TV programs.

It always annoyed/amused me greatly to see a Roman Numeral for 1999 being
shown as 'MCMXCIX' or some similar rubbish when the Romans would naturally
have used 'one less than 2000' or 'IMM'.

Regards,

Jack
Carlos E. R. (02-29-20, 01:01 PM)
On 29/02/2020 03.44, Jack Strangio wrote:
> Allodoxaphobia <trepidation> writes:
>> (Of course, sadly, many had no knowledge of Roman Numerals.)
>> Jonesy

> Most peoples' exposure to Roman Numeral comes from the copyright dates shown
> on various movies and TV programs.


We saw it school, at about 8 or 10 years of age.

> It always annoyed/amused me greatly to see a Roman Numeral for 1999 being
> shown as 'MCMXCIX' or some similar rubbish when the Romans would naturally
> have used 'one less than 2000' or 'IMM'.


Huh, no.
Andreas Kohlbach (02-29-20, 03:15 PM)
On Sat, 29 Feb 2020 02:44:55 -0000 (UTC), Jack Strangio wrote:
> Allodoxaphobia <trepidation> writes:
>> (Of course, sadly, many had no knowledge of Roman Numerals.)
>> Jonesy

> Most peoples' exposure to Roman Numeral comes from the copyright dates shown
> on various movies and TV programs.


I wonder why this is.

Cannot remember if we had to learn Roman numerals at school because other
than "decoding" copyright dates in movies I see no purpose to learn
them. My parents had two fake antique clocks (clocks of modern production
but looking like decades old) with Roman numerals. But I seem to remember
the 4 was IIII instead of IV.

Lastly I heard the youngest generation is not able anymore to read
watches or clocks with hands having Arabic numerals and clocks at schools
get replaced with digital displays. Haven't seen any clocks with hands
here since decades.
John McCue (02-29-20, 03:57 PM)
Carlos E. R. <robin_listas> wrote:
> On 29/02/2020 03.44, Jack Strangio wrote: snip>
>> It always annoyed/amused me greatly to see a Roman Numeral for 1999 being
>> shown as 'MCMXCIX' or some similar rubbish when the Romans would naturally
>> have used 'one less than 2000' or 'IMM'.

> Huh, no.

I was thinking MIM, so off to google and I found this
(FWIW):



It did not mention IMM, but seems people think the longer
version would have been used.

I guess no docs from that period had 1999 written on it :)

John
Andreas Kohlbach (02-29-20, 05:34 PM)
[No quote]

Thanks for your input about Roman numerals. But my intention was to focus
on the regular expression (see subject) to describe what ever a Roman
numeral is. I mean, isn't "^I[XV]|V?I{0-3}$" beautiful in itself?
John McCue (02-29-20, 08:26 PM)
Andreas Kohlbach <ank> wrote:
> [No quote]
> Thanks for your input about Roman numerals. But my intention was to focus
> on the regular expression (see subject) to describe what ever a Roman
> numeral is. I mean, isn't "^I[XV]|V?I{0-3}$" beautiful in itself?


Yes, and I would never have come up with anything close
to that. It is still hard for my mind to wrap around it,
getting dizzy now trying to parse it in my head :)

John
Rich (02-29-20, 09:23 PM)
John McCue <jmccue> wrote:
> Andreas Kohlbach <ank> wrote:
> Yes, and I would never have come up with anything close
> to that. It is still hard for my mind to wrap around it,
> getting dizzy now trying to parse it in my head :)


Just take it apart piece by piece.

| is an "or" statement. Either the left matches, or the right matches.

Left is ^I[XV]

^ is a left anchor, meaning the string has to begin here. So that
expression matches strings starting with I, followed by either an X or
a V.

Right is "V?I{0-3}$"

$ is a right anchor, meaning the string has to end here. ? is an
indicator of 'optionalness' (officially 0 or 1 matches). {0-3} is a
numeric limited match, from zero to three times. So this part matches
zero or one V's, followed by from zero to three I's, at the end of the
string.
Carlos E. R. (02-29-20, 09:51 PM)
On 29/02/2020 16.34, Andreas Kohlbach wrote:
> [No quote]
> Thanks for your input about Roman numerals. But my intention was to focus
> on the regular expression (see subject) to describe what ever a Roman
> numeral is. I mean, isn't "^I[XV]|V?I{0-3}$" beautiful in itself?


Only if you speak the language. To me it is unintelligible.
Robert Riches (03-01-20, 03:10 AM)
On 2020-02-29, Andreas Kohlbach <ank> wrote:
[..]
> watches or clocks with hands having Arabic numerals and clocks at schools
> get replaced with digital displays. Haven't seen any clocks with hands
> here since decades.


Some time ago, I heard of another reason to do at least a little
study of Roman numerals. In Roman numerals, there is no zero.
Among other things, I'm told that means the Romans had no way to
signify successful termination of their C programs. :-)

On a slightly more serious note, can you even imagine trying to
do advanced arithmetic/mathematics in Roman numerals without
computing equipment? Long division in Roman numerals, anyone?

Somewhere, I heard that one of the reasons for the sturdiness of
the old Roman aquaducts and other arch-based structures is the
policy was that the engineer who designed an arch was required to
stand underneath it while the scaffolding was removed. With such
difficulty doing any real math in Roman numerals, the engineers
who were competent and valued their lives would be forced to
seriously overdesign each arch.
The Natural Philosopher (03-01-20, 11:07 AM)
On 01/03/2020 01:10, Robert Riches wrote:
> Somewhere, I heard that one of the reasons for the sturdiness of
> the old Roman aquaducts and other arch-based structures is the
> policy was that the engineer who designed an arch was required to
> stand underneath it while the scaffolding was removed. With such
> difficulty doing any real math in Roman numerals, the engineers
> who were competent and valued their lives would be forced to
> seriously overdesign each arch.


Many years ago I was the graduate engineer involved in doing the design
in a wood and metal fabrication company. In an ex boatyard it also had
plenty of space for other things to be done, and one day the lads were
clustered around the fork lift truck which had finally failed to start
and was about to have its engine removed for an over haul. I glanced up
at the pulley and chain hoist lopped over a not very big wooden roof
beam and yelled 'hang on Id better calculate if that will take the strain"!

"It will" said the chargehand.

"How do you know?"

"We done pulled a bigger 'un out of a truck like that last week".

I reflected on the fundamental philosophical principle of physics, which
is if stuff worked yesterday it will work today, and the contrast
between the theoretical and the practical approach to engineering.

Most engineering consists in doing pretty much what you did yesterday,
again, today.

Arches stay up on account of being constrained laterally. So long as
they are they wont fall down on their own.

The greater danger is the abutments shift laterally.
Andreas Kohlbach (03-01-20, 02:06 PM)
On Sat, 29 Feb 2020 20:51:47 +0100, Carlos E. R. wrote:
> On 29/02/2020 16.34, Andreas Kohlbach wrote:
>> [No quote]
>> Thanks for your input about Roman numerals. But my intention was to focus
>> on the regular expression (see subject) to describe what ever a Roman
>> numeral is. I mean, isn't "^I[XV]|V?I{0-3}$" beautiful in itself?

> Only if you speak the language. To me it is unintelligible.


That is not a language. It's a regular expression found in many
languages, like Perl, Python. Linux/UNIX shells know them. You can tun
them even from inside text editors like vi or Emacs.
The Natural Philosopher (03-01-20, 08:11 PM)
On 01/03/2020 12:06, Andreas Kohlbach wrote:
[..]
Andreas Kohlbach (03-01-20, 09:00 PM)
On Sun, 1 Mar 2020 18:11:24 +0000, The Natural Philosopher wrote:
> On 01/03/2020 12:06, Andreas Kohlbach wrote:
> Regex is a language


I don't think so. It's more than a tool used in various languages.

Regex can be applied in various languages, shells and editors.