# Your first Emma program

Ben Koska, Aug 26, 2026

Loops, conditionals, assignments and functions: everything you need to write a first Emma program.

## Functions and control flow

Emma reads the way you would expect. Here is a function that clamps a value, and one that sums a list with it.

```emma
func clamp(value: Float, min: Float, max: Float) -> Float {
    if value < min { return min }
    if value > max { return max }
    return value
}

func total(values: Float[]) -> Float {
    var sum = 0.0
    for value in values {
        sum = sum + clamp(value, 0.0, 1.0)
    }
    return sum
}
```
