RosettaCodeData/Task/Palindrome-detection/Swift/palindrome-detection-2.swift
2023-07-01 13:44:08 -04:00

5 lines
158 B
Swift

func isPal(str: String) -> Bool {
let c = str.characters
return lazy(c).reverse()
.startsWith(c[c.startIndex...advance(c.startIndex, c.count / 2)])
}