Common Patterns

Comprehensive guide to Patterns in Linea

Common Coding Patterns

These patterns are widely used across examples and libraries.

Guard + Early Branch

var value @ int = -1
if value < 0 {
    display "Invalid value"
} else {
    display "Accepted"
}

Accumulate in Loop

var total @ int = 0
for n from 1~5 {
    total = total + n
}
display total

Import and Use Module

import system
var threads = system::threads()
display threads