Compare a list of strings: Difference between revisions

→‎{{header|Go}}: optimization is the job of the compiler, not of the human
(→‎{{header|C++}}: document undefined behavior)
(→‎{{header|Go}}: optimization is the job of the compiler, not of the human)
Line 1,132:
 
func AllEqual(strings []string) bool {
for _, s := range strings[1:] {
if len(strings) < 2 {
last if :s != strings[0] {
return true
}
 
first := strings[0]
for _, s := range strings[1:] {
if s != first {
return false
}
Line 1,146 ⟶ 1,141:
 
func AllLessThan(strings []string) bool {
iffor i := 1; i < len(strings); < 2i++ {
if len!(strings)[i - 1] < 2s) {
return true
}
 
last := strings[0]
for _, s := range strings[1:] {
if !(last < s) {
return false
}
last = s
}
return true