43 lines
1.3 KiB
Plaintext
43 lines
1.3 KiB
Plaintext
import std::io;
|
|
|
|
# `for const` counts through a range whose ends are known while checking, a copy
|
|
# of its body for each number, in which the variable is a constant: `if const`
|
|
# is decided for each, a fixed array may take its length from it, and a constant
|
|
# parameter or a negative start may be an end. `if const` reads constants, what
|
|
# functions give, and the text of a constant.
|
|
|
|
const count: u64 = 3;
|
|
def twice(n: u64): u64 { return n * 2; }
|
|
const name: strview = "sakura";
|
|
const four: u64 = 2 * 2;
|
|
struct box { var a: u64; }
|
|
def box::limit(): u64 { return 2; }
|
|
def pick<const N: u64>(): void {
|
|
for const i in 0..N {
|
|
if const i % 2 == 0 { print($"even{i} "); } else { print($"odd{i} "); }
|
|
}
|
|
println("");
|
|
}
|
|
|
|
def main(): void {
|
|
for const i in 0..count { print($"i{i} "); }
|
|
println("");
|
|
for const j in 0..2 * 2 { print($"j{j} "); }
|
|
println("");
|
|
for const k in 1..count + 1 { print($"k{k} "); }
|
|
println("");
|
|
for const n in -2..2 { print($"n{n} "); }
|
|
println("");
|
|
for const f in 0..four {
|
|
if const f == 1 { continue; }
|
|
if const f == 3 { break; }
|
|
var held: u8[f + 1];
|
|
print($"f{f}:{held.length} ");
|
|
}
|
|
println("");
|
|
pick::<5>();
|
|
for const e in 3..1 { print("never"); }
|
|
if const twice(count) == 6 && name[1] == 'a' && box::limit() < 3 { println("decided"); }
|
|
println("end");
|
|
}
|