Skip to content

Array minimum

Go find smallest

Flowchart (ISO 5807)

YesNoStartInput am = a[0]x ∈ ax < mm = xReturn mEndFigure 1 — minOf

Source code

Go
func minOf(a []int) int {
    m := a[0]
    for _, x := range a {
        if x < m {
            m = x
        }
    }
    return m
}

The editor opens with this code — change it and the chart redraws.

Language
Go
Constructs
find smallest
Topic
Algorithms
Formats
Word, Visio, draw.io, PDF, SVG

Related examples