Examples · learn/08-collections · 144 of 339
task-1.solution
tin run examples/learn/08-collections/task-1.solution.tinfn largest(xs: int[]): Option<int> {
if xs.isEmpty() { return None }
var best = xs[0]
for x in xs {
if x > best { best = x }
}
Some(best)
}
fn main() {
print(largest([4, 19, 7]))
let none: int[] = []
print(largest(none))
}