/** * Beispiel aus * * - Algorithmen und Datenstrukturen für Dummies * - von Andreas Gogol-Döring und Thomas Letschert * - Verlag Wiley-VCH; Oktober 2019 * - Kapitel 2, Qualität von Algorithmen * * @author A. Gogol-Döring, Th. Letschert */ import Foundation struct AuD_02_02_LexicalFirst { static func LexicalFirst(T: [String]) -> String { if (T.count == 0) { return "" } else { var f = T[0] for s in T.dropFirst() { if (s < f) { f = s } } return f } } static func run() { let words = ["a", "b", "c", "die", "Katze", "lief", "im", "Schnee"] let first = LexicalFirst(T: words) print(first) } }