Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Range Arrays

Alternatively a range expression can be used to generate an array with consecutive values.

[!IMPORTANT] µcad ranges include start and end point! This is different in many other programming languages. So in µcad [1..3] results in [1,2,3].

test

std::debug::assert_eq([[1..5], [1, 2, 3, 4, 5]]);
std::debug::assert_eq([[-2..2], [-2, -1, 0, 1, 2]]);

The order of the endpoints of a range is important.

test

[6..1]; // error
[2..-2]; // error

Only Integer can be used as endpoint.

test

[1.0..2.0]; // parse_error