RosettaCodeData/Task/Odd-word-problem/V-(Vlang)/odd-word-problem.v
2023-07-01 13:44:08 -04:00

24 lines
464 B
V

const str = 'what,is,the;meaning,of:life.'
fn main() {
mut temp, mut new_str := '', ''
mut switch := true
for field in str {
temp += field.ascii_str()
if field.is_alnum() == false {
if switch == true {
new_str += temp
temp =''
switch = false
continue
}
else {
new_str += temp.all_before_last(field.ascii_str()).reverse() + field.ascii_str()
temp =''
switch = true
continue
}
}
}
println(new_str)
}