News for hackers. Stuff that matters.
Re:How Did Anyone Do Math in Roman Numerals? by MichaelBurge on Friday July 21, 2017 @06:22AM (#14819307)
In 2017 we just do:

    $ perl6 -e 'say Ⅻ / Ⅲ'
    4
Re:How Did Anyone Do Math in Roman Numerals? by fahadkhan on Friday July 21, 2017 @08:00AM (#14819669)
care to explain why this works?
Re:How Did Anyone Do Math in Roman Numerals? by raiph on Friday July 21, 2017 @08:36PM (#14824766)
What do you mean?

Perhaps you mean "how" rather than "why". Others have answered with the gory "how" details.

Perhaps you mean "why would anyone think to make this work?" To the degree anyone thought "let's make this work", the "this" was adopting the full Unicode vision -- decent digital support for the many native languages humans use (from Arabic to Zulu).

Perhaps you mean "why" as in "why would someone write the underlying language/compiler code that makes Latin math work?" Some old languages, like Latin, just happen to have been automatically enabled too. Some compiler dev would have to write code to stop it working.

Perhaps you mean "why would weird Unicode characters be acceptable in a programming language's source code?" Because P6 defers to the Unicode standard by default for determining what languages and characters may be included in source code.

This in turn allows everyone on the planet to feel welcome to write code in their native language and/or use characters they're familiar with in their line of work. (For example mathematicians can use the appropriate mathematical symbols to express themselves in P6 code.)

Re:How Did Anyone Do Math in Roman Numerals? by yorwba on Friday July 21, 2017 @08:14AM (#14819743)
Unicode has codepoints for roman numerals 1 through 12 and then the base symbols up to one hundred thousand (ↈ) which I just saw for the first time.

That Perl allows them in integer literals is strange, but also logical in a weird way. (Now I wonder what other number systems it supports.)

EDIT: Ok, so I installed perl6 (rakudo) just to test this out, and it apparently doesn't work out of the box. Pity.

Re:How Did Anyone Do Math in Roman Numerals? by MichaelBurge on Friday July 21, 2017 @11:01AM (#14821060)
I'm not a compiler dev, but it looks fairly new and appears to have many other special Unicode ranges too, including camels and beer mugs???

https://github.com/rakudo/rakudo/blob/beec02a6fa69e3ac290b4d...

Re:How Did Anyone Do Math in Roman Numerals? by zoffix222 on Friday July 21, 2017 @06:23PM (#14824163)
That's just a helper script to generate tables for for .succ/.pred string increment/decrement methods. Nd and No chars as numeric literals were available since first stable release in December 2015
Re:How Did Anyone Do Math in Roman Numerals? by zoffix222 on Friday July 21, 2017 @06:22PM (#14824153)
> EDIT: Ok, so I installed perl6 (rakudo) just to test this out, and it apparently doesn't work out of the box. Pity.

By any chance, was it from system packages that are likely outdated? You can get up-to-date packages [here](https://github.com/nxadm/rakudo-pkg/releases) or for Windows/Mac, use [Rakudo Star](http://rakudo.org/downloads/star/). Anything older than 2017.04 is ancient and anything older than 2015.12 precedes first stable release and is likely broken.

> Now I wonder what other number systems it supports

It goes by Unicode's definition of what's a digit or a number (using Nd and No) properties. Nd chars are "digits" and can be combined. `No` chars are "Numeric other" and can't be combined; can only use them as numeric literals. [Among other things](https://docs.perl6.org/language/unicode_texas.html#Numeric_c...), that includes Unicodey fractions. And as a cherry on top, you can use superscript chars to raise to a power:

    $ rakudo -e 'say ½ + 42²'
    1764.5
Here are all the Nd and No chars that can be used as numeric literals:

    $ rakudo -e 'put (^0x110000).grep(*.uniprop eq any <Nd No>)».chr'                                                                                                                                                                            
    0 1 2 3 4 5 6 7 8 9 ² ³ ¹ ¼ ½ ¾ ٠ ١ ٢ ٣ ٤ ٥ ٦ ٧ ٨ ٩ ۰ ۱ ۲ ۳ ۴ ۵ ۶ ۷ ۸ ۹ ߀ ߁
    ߂ ߃ ߄ ߅ ߆ ߇ ߈ ߉ ० १ २ ३ ४ ५ ६ ७ ८ ९ ০ ১ ২ ৩ ৪ ৫ ৬ ৭ ৮ ৯ ৴ ৵ ৶ ৷ ৸ ৹ ੦ ੧ ੨ ੩
    ੪ ੫ ੬ ੭ ੮ ੯ ૦ ૧ ૨ ૩ ૪ ૫ ૬ ૭ ૮ ૯ ୦ ୧ ୨ ୩ ୪ ୫ ୬ ୭ ୮ ୯ ୲ ୳ ୴
    ୵ ୶ ୷ ௦ ௧ ௨ ௩ ௪ ௫ ௬ ௭ ௮ ௯ ௰ ௱ ௲ ౦ ౧ ౨ ౩ ౪ ౫ ౬ ౭ ౮ ౯ ౸
    ౹ ౺ ౻ ౼ ౽ ౾ ೦ ೧ ೨ ೩ ೪ ೫ ೬ ೭ ೮ ೯ ൘ ൙ ൚ ൛ ൜ ൝ ൞ ൦ ൧ ൨ ൩ ൪ 
    ൫ ൬ ൭ ൮ ൯ ൰ ൱ ൲ ൳ ൴ ൵ ൶ ൷ ൸ ෦ ෧ ෨ ෩ ෪ ෫ ෬ ෭ ෮ ෯ ๐ ๑ ๒ ๓ ๔ ๕
     ๖ ๗ ๘ ๙ ໐ ໑ ໒ ໓ ໔ ໕ ໖ ໗ ໘ ໙ ༠ ༡ ༢ ༣ ༤ ༥ ༦ ༧ ༨ ༩ ༪ ༫ ༬ ༭ ༮ ༯ ༰ 
     ༱ ༲ ༳ ၀ ၁ ၂ ၃ ၄ ၅ ၆ ၇ ၈ ၉ ႐ ႑ ႒ ႓ ႔ ႕ ႖ ႗ ႘ ႙ ፩ ፪ ፫ ፬ ፭ 
     ፮ ፯ ፰ ፱ ፲ ፳ ፴ ፵ ፶ ፷ ፸ ፹ ፺ ፻ ፼ ០ ១ ២ ៣ ៤ ៥ ៦ ៧ ៨ ៩ ៰ ៱ ៲ 
     ៳ ៴ ៵ ៶ ៷ ៸ ៹ ᠐ ᠑ ᠒ ᠓ ᠔ ᠕ ᠖ ᠗ ᠘ ᠙ ᥆ ᥇ ᥈ ᥉ ᥊ ᥋ ᥌ ᥍ ᥎ ᥏ ᧐ ᧑ 
     ᧒ ᧓ ᧔ ᧕ ᧖ ᧗ ᧘ ᧙ ᧚ ᪀ ᪁ ᪂ ᪃ ᪄ ᪅ ᪆ ᪇ ᪈ ᪉ ᪐ ᪑ ᪒ ᪓ ᪔ ᪕ ᪖ ᪗ 
     ᪘ ᪙ ᭐ ᭑ ᭒ ᭓ ᭔ ᭕ ᭖ ᭗ ᭘ ᭙ ᮰ ᮱ ᮲ ᮳ ᮴ ᮵ ᮶ ᮷ ᮸ ᮹ ᱀ ᱁ ᱂ ᱃ ᱄ 
     ᱅ ᱆ ᱇ ᱈ ᱉ ᱐ ᱑ ᱒ ᱓ ᱔ ᱕ ᱖ ᱗ ᱘ ᱙ ⁰ ⁴ ⁵ ⁶ ⁷ ⁸ ⁹ ₀ ₁ ₂ ₃ ₄ ₅ ₆ ₇ ₈ ₉ ⅐ ⅑ 
     ⅒ ⅓ ⅔ ⅕ ⅖ ⅗ ⅘ ⅙ ⅚ ⅛ ⅜ ⅝ ⅞ ⅟ ↉ ① ② ③ ④ ⑤ ⑥ ⑦ ⑧ ⑨ ⑩ ⑪ ⑫ ⑬ ⑭ ⑮ 
     ⑯ ⑰ ⑱ ⑲ ⑳ ⑴ ⑵ ⑶ ⑷ ⑸ ⑹ ⑺ ⑻ ⑼ ⑽ ⑾ ⑿ ⒀ ⒁ ⒂ ⒃ ⒄ ⒅ ⒆ ⒇ ⒈ ⒉ 
     ⒊ ⒋ ⒌ ⒍ ⒎ ⒏ ⒐ ⒑ ⒒ ⒓ ⒔ ⒕ ⒖ ⒗ ⒘ ⒙ ⒚ ⒛ ⓪ ⓫ ⓬ ⓭ ⓮ ⓯ ⓰ ⓱ ⓲ 
     ⓳ ⓴ ⓵ ⓶ ⓷ ⓸ ⓹ ⓺ ⓻ ⓼ ⓽ ⓾ ⓿                
                    ⳽ ㆒ ㆓ ㆔ ㆕ ㈠ ㈡ ㈢ ㈣ ㈤ ㈥ ㈦ ㈧ ㈨ 
     ㈩ ㉈ ㉉ ㉊ ㉋ ㉌ ㉍ ㉎ ㉏ ㉑ ㉒ ㉓ ㉔ ㉕ ㉖ ㉗ ㉘ ㉙ ㉚ ㉛ ㉜ ㉝ ㉞ ㉟ ㊀ ㊁ ㊂ 
     ㊃ ㊄ ㊅ ㊆ ㊇ ㊈ ㊉ ㊱ ㊲ ㊳ ㊴ ㊵ ㊶ ㊷ ㊸ ㊹ ㊺ ㊻ ㊼ ㊽ ㊾ ㊿ ꘠ ꘡ ꘢ ꘣ ꘤ ꘥ 
     ꘦ ꘧ ꘨ ꘩ ꠰ ꠱ ꠲ ꠳ ꠴ ꠵ ꣐ ꣑ ꣒ ꣓ ꣔ ꣕ ꣖ ꣗ ꣘ ꣙ ꤀ ꤁ ꤂ ꤃ ꤄ ꤅ ꤆ 
     ꤇ ꤈ ꤉ ꧐ ꧑ ꧒ ꧓ ꧔ ꧕ ꧖ ꧗ ꧘ ꧙ ꧰ ꧱ ꧲ ꧳ ꧴ ꧵ ꧶ ꧷ ꧸ ꧹ ꩐ ꩑ ꩒ 
     ꩓ ꩔ ꩕ ꩖ ꩗ ꩘ ꩙ ꯰ ꯱ ꯲ ꯳ ꯴ ꯵ ꯶ ꯷ ꯸ ꯹ 0 1 2 3 4 5 6 7 8 
     9 𐄇 𐄈 𐄉 𐄊 𐄋 𐄌 𐄍 𐄎 𐄏 𐄐 𐄑 𐄒 𐄓 𐄔 𐄕 𐄖 𐄗 𐄘 𐄙 𐄚 𐄛 𐄜 𐄝 𐄞 𐄟 𐄠 𐄡 𐄢 𐄣 𐄤 𐄥 𐄦 𐄧 
     𐄨 𐄩 𐄪 𐄫 𐄬 𐄭 𐄮 𐄯 𐄰 𐄱 𐄲 𐄳 𐅵 𐅶 𐅷 𐅸 𐆊 𐆋 𐋡 𐋢 𐋣 𐋤 𐋥 𐋦 𐋧 𐋨 𐋩 𐋪 𐋫 𐋬 𐋭 𐋮 𐋯 𐋰 𐋱 
     𐋲 𐋳 𐋴 𐋵 𐋶 𐋷 𐋸 𐋹 𐋺 𐋻 𐌠 𐌡 𐌢 𐌣 𐒠 𐒡 𐒢 𐒣 𐒤 𐒥 𐒦 𐒧 𐒨 𐒩 𐡘 𐡙 𐡚 𐡛 𐡜 𐡝 𐡞 𐡟 𐡹 𐡺 𐡻 
     𐡼 𐡽 𐡾 𐡿 𐢧 𐢨 𐢩 𐢪 𐢫 𐢬 𐢭 𐢮 𐢯 𐣻 𐣼 𐣽 𐣾 𐣿 𐤖 𐤗 𐤘 𐤙 𐤚 𐤛 𐦼 𐦽 𐧀 𐧁 𐧂 𐧃 𐧄 𐧅 𐧆 𐧇 𐧈 𐧉 
     𐧊 𐧋 𐧌 𐧍 𐧎 𐧏 𐧒 𐧓 𐧔 𐧕 𐧖 𐧗 𐧘 𐧙 𐧚 𐧛 𐧜 𐧝 𐧞 𐧟 𐧠 𐧡 𐧢 𐧣 𐧤 𐧥 𐧦 𐧧 𐧨 𐧩 𐧪 𐧫 𐧬 𐧭 𐧮 
     𐧯 𐧰 𐧱 𐧲 𐧳 𐧴 𐧵 𐧶 𐧷 𐧸 𐧹 𐧺 𐧻 𐧼 𐧽 𐧾 𐧿 𐩀 𐩁 𐩂 𐩃 𐩄 𐩅 𐩆 𐩇 𐩽 𐩾 𐪝 𐪞 𐪟 𐫫 𐫬 𐫭 𐫮 𐫯 
     𐭘 𐭙 𐭚 𐭛 𐭜 𐭝 𐭞 𐭟 𐭸 𐭹 𐭺 𐭻 𐭼 𐭽 𐭾 𐭿 𐮩 𐮪 𐮫 𐮬 𐮭 𐮮 𐮯 𐳺 𐳻 𐳼 𐳽 𐳾 𐳿 𐹠 𐹡 𐹢 𐹣 𐹤 𐹥 
     𐹦 𐹧 𐹨 𐹩 𐹪 𐹫 𐹬 𐹭 𐹮 𐹯 𐹰 𐹱 𐹲 𐹳 𐹴 𐹵 𐹶 𐹷 𐹸 𐹹 𐹺 𐹻 𐹼 𐹽 𐹾 𑁒 𑁓 𑁔 𑁕 𑁖 𑁗 𑁘 𑁙 𑁚 𑁛 
     𑁜 𑁝 𑁞 𑁟 𑁠 𑁡 𑁢 𑁣 𑁤 𑁥 𑁦 𑁧 𑁨 𑁩 𑁪 𑁫 𑁬 𑁭 𑁮 𑁯 𑃰 𑃱 𑃲 𑃳 𑃴 𑃵 𑃶 𑃷 𑃸 𑃹 𑄶 𑄷 𑄸 𑄹 𑄺 
     𑄻 𑄼 𑄽 𑄾 𑄿 𑇐 𑇑 𑇒 𑇓 𑇔 𑇕 𑇖 𑇗 𑇘 𑇙 𑇡 𑇢 𑇣 𑇤 𑇥 𑇦 𑇧 𑇨 𑇩 𑇪 𑇫 𑇬 𑇭 𑇮 𑇯 𑇰 𑇱 𑇲 𑇳 𑇴 
     𑋰 𑋱 𑋲 𑋳 𑋴 𑋵 𑋶 𑋷 𑋸 𑋹 𑑐 𑑑 𑑒 𑑓 𑑔 𑑕 𑑖 𑑗 𑑘 𑑙 𑓐 𑓑 𑓒 𑓓 𑓔 𑓕 𑓖 𑓗 𑓘 𑓙 𑙐 𑙑 𑙒 𑙓 𑙔 
     𑙕 𑙖 𑙗 𑙘 𑙙 𑛀 𑛁 𑛂 𑛃 𑛄 𑛅 𑛆 𑛇 𑛈 𑛉 𑜰 𑜱 𑜲 𑜳 𑜴 𑜵 𑜶 𑜷 𑜸 𑜹 𑜺 𑜻 𑣠 𑣡 𑣢 𑣣 𑣤 𑣥 𑣦 𑣧 
     𑣨 𑣩 𑣪 𑣫 𑣬 𑣭 𑣮 𑣯 𑣰 𑣱 𑣲 𑱐 𑱑 𑱒 𑱓 𑱔 𑱕 𑱖 𑱗 𑱘 𑱙 𑱚 𑱛 𑱜 𑱝 𑱞 𑱟 𑱠 𑱡 𑱢 𑱣 𑱤 𑱥 𑱦 𑱧 
     𑱨 𑱩 𑱪 𑱫 𑱬 𖩠 𖩡 𖩢 𖩣 𖩤 𖩥 𖩦 𖩧 𖩨 𖩩 𖭐 𖭑 𖭒 𖭓 𖭔 𖭕 𖭖 𖭗 𖭘 𖭙 𖭛 𖭜 𖭝 𖭞 𖭟 𖭠 𖭡 𝍠 𝍡 𝍢 
     𝍣 𝍤 𝍥 𝍦 𝍧 𝍨 𝍩 𝍪 𝍫 𝍬 𝍭 𝍮 𝍯 𝍰 𝍱 𝟎 𝟏 𝟐 𝟑 𝟒 𝟓 𝟔 𝟕 𝟖 𝟗 𝟘 𝟙 𝟚 𝟛 𝟜 𝟝 𝟞 𝟟 𝟠 𝟡 𝟢 
     𝟣 𝟤 𝟥 𝟦 𝟧 𝟨 𝟩 𝟪 𝟫 𝟬 𝟭 𝟮 𝟯 𝟰 𝟱 𝟲 𝟳 𝟴 𝟵 𝟶 𝟷 𝟸 𝟹 𝟺 𝟻 𝟼 𝟽 𝟾 𝟿 𞣇 𞣈 𞣉 𞣊 𞣋 
     𞣌 𞣍 𞣎 𞣏 𞥐 𞥑 𞥒 𞥓 𞥔 𞥕 𞥖 𞥗 𞥘 𞥙 🄀 🄁 🄂 🄃 🄄 🄅 🄆 🄇 🄈 🄉 🄊 🄋 🄌
Re:How Did Anyone Do Math in Roman Numerals? by wambotron on Friday July 21, 2017 @11:14AM (#14821172)
Weird, I just installed it (via homebrew) and it's working for me
Re:How Did Anyone Do Math in Roman Numerals? by yorwba on Friday July 21, 2017 @12:43PM (#14821893)
I used the version from the Ubuntu Xenial package repositories, and that perl was apparently from November 2015. I guess such is life when you go with long-term support and stable packages.
Re:How Did Anyone Do Math in Roman Numerals? by zoffix222 on Friday July 21, 2017 @05:48PM (#14823954)
Ouch. That's older than first stable release :)