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

→‎Raku: use Bag
(→‎Raku: use Bag)
Line 3,713:
Raku 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 11 characters and that the delta with a combining circumflex in position 6 is not the same as the deltas without in positions 5 & 9.
 
<syntaxhighlight lang="raku" line=""> -> $str {
my $i = 0;
print "\n{$str.raku} (length: {$str.chars}), has ";
my %m = $str.comb.Bag;
%m{$_}.push: ++$i for $str.comb;
if any(%m.values) > 1 {
say "duplicated characters:";
1,934

edits