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

no edit summary
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.bytesrunes()
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].ascii_str()}' (0x${chars[i]:x}) is different at position ${i+1}.\n")
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>
 
338

edits