✓
Passing This code compiles and runs correctly.
Code
~import std/io
const std = @import("std");
var input_n: u64 = 0;
~pub event read-n {}
~proc read-n|zig {
var args = std.process.args();
_ = args.next();
if (args.next()) |arg| {
input_n = std.fmt.parseInt(u64, arg, 10) catch 1_000_000;
} else {
input_n = 1_000_000;
}
}
~pub event sum-range { n: u64 }
! v { item: u64, acc: u64 } -> u64
| done u64
~proc sum-range|zig {
var acc: u64 = 0;
for (0..n) |i| {
acc = v(.{ .item = i, .acc = acc });
}
return .{ .done = acc };
}
~read-n()
~sum-range(n: input_n)
! v p -> p.acc + p.item
| done r |> std/io:print.ln("sum = {{ r:d }}")
Actual
sum = 4950
Expected output
sum = 4950
Flows
flow ~read-n click a branch to expand · @labels scroll to their anchor
read-n
flow ~sum-range click a branch to expand · @labels scroll to their anchor
sum-range (n: input_n)
Test Configuration
MUST_RUN