Determine if a string has all the same characters: Difference between revisions
Determine if a string has all the same characters (view source)
Revision as of 11:37, 2 June 2022
, 1 year agono edit summary
Thundergnat (talk | contribs) m (→{{header|Vlang}}: Use Vlang header instead of Wren header) |
No edit summary |
||
Line 3,478:
{{trans|Go}}
<lang vlang>fn analyze(s string) {
chars := s.
le := chars.len
println("Analyzing $s which has a length of $le:")
Line 3,485:
if chars[i] != chars[i-1] {
println(" Not all characters in the string are the same.")
println(" '${chars[i]
return
}
Line 3,501:
".55",
"tttTTT",
"4444 444k",
"pépé",
"🐶🐶🐺🐶",
"🎄🎄🎄🎄"
]
for s in strings {
Line 3,533 ⟶ 3,536:
Not all characters in the string are the same.
' ' (0x20) is different at position 5.
Analyzing pépé which has a length of 4:
Not all characters in the string are the same.
'é' (0xe9) is different at position 2.
Analyzing 🐶🐶🐺🐶 which has a length of 4:
Not all characters in the string are the same.
'🐺' (0x1f43a) is different at position 3.
Analyzing 🎄🎄🎄🎄 which has a length of 4:
All characters in the string are the same.
</pre>
|