Determine if a string has all the same characters: Difference between revisions

Content deleted Content added
Thundergnat (talk | contribs)
m →‎{{header|Perl 6}}: Add another multi-byte example
Thundergnat (talk | contribs)
m →‎{{header|Perl 6}}: whitespace regularize
Line 225: Line 225:


if %m > 1 {
if %m > 1 {
say "different characters:";
say "different characters:";
say "'{.key}' ({.key.uninames}; hex ordinal: {(.key.ords).fmt: "0x%X"})" ~
say "'{.key}' ({.key.uninames}; hex ordinal: {(.key.ords).fmt: "0x%X"})" ~
" in positions: {.value.sort.squish.join: ', '}" for %m.sort( *.value[0] );
" in positions: {.value.sort.squish.join: ', '}" for %m.sort( *.value[0] );
Line 254: Line 254:
"333" (length: 3), has the same character in all positions.
"333" (length: 3), has the same character in all positions.


".55" (length: 3), has different characters:
".55" (length: 3), has different characters:
'.' (FULL STOP; hex ordinal: 0x2E) in positions: 1
'.' (FULL STOP; hex ordinal: 0x2E) in positions: 1
'5' (DIGIT FIVE; hex ordinal: 0x35) in positions: 2, 3
'5' (DIGIT FIVE; hex ordinal: 0x35) in positions: 2, 3


"tttTTT" (length: 6), has different characters:
"tttTTT" (length: 6), has different characters:
't' (LATIN SMALL LETTER T; hex ordinal: 0x74) in positions: 1, 2, 3
't' (LATIN SMALL LETTER T; hex ordinal: 0x74) in positions: 1, 2, 3
'T' (LATIN CAPITAL LETTER T; hex ordinal: 0x54) in positions: 4, 5, 6
'T' (LATIN CAPITAL LETTER T; hex ordinal: 0x54) in positions: 4, 5, 6


"4444 444k" (length: 9), has different characters:
"4444 444k" (length: 9), has different characters:
'4' (DIGIT FOUR; hex ordinal: 0x34) in positions: 1, 2, 3, 4, 6, 7, 8
'4' (DIGIT FOUR; hex ordinal: 0x34) in positions: 1, 2, 3, 4, 6, 7, 8
' ' (SPACE; hex ordinal: 0x20) in positions: 5
' ' (SPACE; hex ordinal: 0x20) in positions: 5