Hacker News new | past | comments | ask | show | jobs | submit login

Raku also has a specific string type (Str) that is not just a bag of bytes. Strings are normalized (NFC) when they are created, and multi-codepoint graphemes are represented internally using synthetic codepoints (negative integers), but this is all opaque to the user. This also means that string indexing in Raku is O(1).

Raku passes all the tests. He mentions he didn't find any language that upper-cases "baffle" correctly but Raku does.

Here's my REPL test

    > my $n = "noe\x[0308]l"
    noël
    > $n.chars
    4
    > $n.flip
    lëon
    > $n.substr(0, 3)
    noë
    > my $b = "baffle"
    baffle
    > $b.substr(2, 1).uniname
    LATIN SMALL LIGATURE FFL
    > $b.uc
    BAFFLE
    > "noe\x[0308]l" eq "no\x[00EB]l"
    True
HN doesn't handle the cat emojis, so they are not included, but they worked fine.



Technically it is MoarVM that handles graphemes as synthetic codepoints.

We call it NFG for Normalized Form Grapheme.

The JVM and JavaScript backends currently use the built-in string handling features. Which means that they are just as broken as the rest of the code running on them.

---

Of further note, you can use ignorecase in regexes to match "baffle".

    "baffle" ~~ /:ignorecase  BAFfLE  /;




Applications are open for YC Winter 2022

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: