Determine if a string has all unique characters: Difference between revisions

→‎{{header|Perl 6}}: Add capability to detect multiple characters repeated multiple times and demonstrate
m (→‎{{header|Perl 6}}: grammar fix)
(→‎{{header|Perl 6}}: Add capability to detect multiple characters repeated multiple times and demonstrate)
Line 37:
=={{header|Perl 6}}==
{{works with|Rakudo|2019.07.1}}
Perl 6 works with unicode natively and handles combining characters and multi-byte emoji correctly. In the last string, notice the the length is correctly shown as 1011 characters and that the delta with a combining circumflex in position 6 is not the same as the deltas without in positions 5 & 89.
 
<lang perl6> -> $str {
print "\n{$str.perl} (length: {$str.chars}), has ";
if my $match = $str.match( / (.).*$0 /, :exhaustiveex ) {
my %m;
%m{.values.Str}.append(flat 1 + .from, .pos) for $match.list;
say "duplicated characters:";
say "'{.values.Strkey}' ({.values.Strkey.uninames}; hex ordinal: {(.values.Strkey.ords).fmt: "0x%X"})" ~
" in positions: {.value.sort.squish.join: ', ',}" flat 1 +for %m.from,sort( *.pos}"value[0] for $match.list);
} else {
say "no duplicated characters."
}
} for flat
'',
'.',
Line 54 ⟶ 56:
'XYZ ZYX',
'1234567890ABCDEFGHIJKLMN0PQRSTUVWXYZ',
'01234567890ABCDEFGHIJKLMN0PQRSTUVWXYZ0X',
'🦋🙂👨‍👩‍👧‍👦🙄ΔΔ̂🦋Δ👍👨‍👩‍👧‍👦'</lang>
'🦋🙂👨‍👩‍👧‍👦🙄ΔΔ̂ 🦋Δ👍👨‍👩‍👧‍👦'</lang>
{{out}}
<pre>"" (length: 0), has no duplicated characters.
Line 70 ⟶ 73:
'0' (DIGIT ZERO; hex ordinal: 0x30) in positions: 10, 25
 
"🦋🙂👨‍👩‍👧‍👦🙄ΔΔ̂🦋Δ👍👨‍👩‍👧‍👦01234567890ABCDEFGHIJKLMN0PQRSTUVWXYZ0X" (length: 1039), has duplicated characters:
'🦋0' (BUTTERFLYDIGIT ZERO; hex ordinal: 0x1F98B0x30) in positions: 1, 711, 26, 38
'👨‍👩‍👧‍👦X' (MANLATIN ZEROCAPITAL WIDTHLETTER JOINER WOMAN ZERO WIDTH JOINER GIRL ZERO WIDTH JOINER BOYX; hex ordinal: 0x1F468 0x200D 0x1F469 0x200D 0x1F467 0x200D 0x1F4660x58) in positions: 335, 1039
 
'Δ' (GREEK CAPITAL LETTER DELTA; hex ordinal: 0x394) in positions: 5, 8</pre>
"🦋🙂👨‍👩‍👧‍👦🙄ΔΔ̂ 🦋Δ👍👨‍👩‍👧‍👦" (length: 11), has duplicated characters:
'🦋' (BUTTERFLY; hex ordinal: 0x1F98B) in positions: 1, 8
'👨‍👩‍👧‍👦' (MAN ZERO WIDTH JOINER WOMAN ZERO WIDTH JOINER GIRL ZERO WIDTH JOINER BOY; hex ordinal: 0x1F468 0x200D 0x1F469 0x200D 0x1F467 0x200D 0x1F466) in positions: 3, 11
'Δ' (GREEK CAPITAL LETTER DELTA; hex ordinal: 0x394) in positions: 5, 8</pre>9
</pre>
 
=={{header|REXX}}==
10,343

edits