1, 5, 100, 2, 7 становится 5, 100, 7 < /p>
1, 2, 18, 19, 5, 4 становится 2, 19, 5 < /p>
Код: Выделить всё
extension Array where Element: Comparable {
///Simply return the bigger of each pair of (say) integers as we go
///along. (If there's an odd count, of course the last solo one is
///just that value.)
var biggerOfPairs: [Element] {
// var safely: [Element] = []
// if self.count % 2 == 1 { safely.append(Element.min) }
// var result: [Element] = []
// for i in 0..
Подробнее здесь: [url]https://stackoverflow.com/questions/79670693/i-was-disappointed-to-discover-comparable-seems-to-have-no-min-call-is-that-co[/url]