Compare a list of strings: Difference between revisions
Content added Content deleted
(→{{header|C++}}: document undefined behavior) |
(→{{header|Go}}: optimization is the job of the compiler, not of the human) |
||
Line 1,132: | Line 1,132: | ||
func AllEqual(strings []string) bool { |
func AllEqual(strings []string) bool { |
||
⚫ | |||
⚫ | |||
⚫ | |||
return true |
|||
} |
|||
first := strings[0] |
|||
⚫ | |||
if s != first { |
|||
return false |
return false |
||
} |
} |
||
Line 1,146: | Line 1,141: | ||
func AllLessThan(strings []string) bool { |
func AllLessThan(strings []string) bool { |
||
for i := 1; i < len(strings); i++ { |
|||
⚫ | |||
return true |
|||
} |
|||
⚫ | |||
for _, s := range strings[1:] { |
|||
if !(last < s) { |
|||
return false |
return false |
||
} |
} |
||
last = s |
|||
} |
} |
||
return true |
return true |