This walkthrough is for the Scarp v0.0.5-alpha.1 interpreter. Its source and expected output below are copied without changes from the released vectors fixture. Both language editions are checked against the pinned compiler examples.
Create a UTF-8 file named vectors.srp. This is one complete runnable program, not a collection of independent snippets:
bind values = [1.0, 2.0, 3.0, 4.0];
print(values, len(values), values[0]);
var weights = [0.2, 0.3, 0.5];
bind snapshot = weights;
weights = scale(weights, 2.0);
print(snapshot);
print(weights);
print(sum(values), mean(values));
print(dot(values, [2.0, -1.0, 0.5, 2.0]));
print(mse([1.0, 2.0], [1.0, 4.0]));
print(clamp([-2.0, 0.5, 3.0], 0.0, 1.0));
print(fill(1.5, 3));
Run the program from the folder containing your file:
scarp check vectors.srp
scarp run vectors.srpThe expected stdout of run is exactly:
[1.0, 2.0, 3.0, 4.0] 4 1.0
[0.2, 0.3, 0.5]
[0.4, 0.6, 1.0]
10.0 2.5
9.5
2.0
[0.0, 0.5, 1.0]
[1.5, 1.5, 1.5]
The output matches the compiler's published stdout fixture.
[1.0, 2.0, 3.0, 4.0]is a numerical vector;len(values)reports its length andvalues[0]selects its first element.bind snapshot = weightskeeps the earlier value, while reassignment throughvar weightsstores the result ofscale(weights, 2.0). The earlier snapshot remains unchanged.sumadds elements;meancomputes their average.dotcombines matching vector positions;msecomputes mean squared error for two equal-length vectors.clampbounds each element between0.0and1.0, whilefill(1.5, 3)constructs three identical entries.
Change the values in your own copy and repeat scarp check vectors.srp before scarp run vectors.srp. Your modified program will not necessarily have the same output as the fixture above. Scarp checks vector dimensions, and invalid numeric operations can produce diagnostics. Review numeric types and vectors, diagnostics, and runtime budgets.
The source modules walkthrough combines a tile matrix and a vector through matvec; its complete file contents and output are also checked against the published compiler. Use the verified functions tutorial if function calls are new to you.
::: warning Prerelease compatibility This is a demonstration of the pinned v0.0.5-alpha.1 interpreter, not evidence that these operations are available in older or future releases. Refer to feature status. :::