← All examples

Geometry

The root of the strike: its items are geometry::… from outside.

geometry/strike.zg
# The root of the strike: its items are `geometry::…` from outside.

bare.never [fn, struct];

const 'unit' := 1.0;

fn helper [] -> str.utf8 { return "from the root"; }

module report {
    pub.strike fn line ['label': str.utf8, 'v': bin64] {
        std::print.useful['label', ": ", 'v', newln];
    }
}

MAIN {
    report.line["circle", shapes.circle.area[2.0]];
    report.line["square", shapes.square.area[3.0]];
    report.line["unit circle", shapes.circle.area['unit']];
    std::print.useful[shapes.describe[], newln];
    let 'r': shapes.circle.Circle = shapes.circle.Circle[radius = 1.5];
    std::print.useful['r'.radius, " ", shapes.circle.'pi', newln];
}
Output
circle: 12.566370614359172
square: 9
unit circle: 3.141592653589793
from the root, circle, square
1.5 3.141592653589793