feat: toy tutorial chapter 1.

This commit is contained in:
2025-05-29 15:53:58 +08:00
commit 1a64b78ef8
8 changed files with 1507 additions and 0 deletions

13
examples/transpose.hello Normal file
View File

@@ -0,0 +1,13 @@
def main() {
# Define a variable `a` with shape <2, 3>, initialized with the literal value.
# The shape is inferred from the supplied literal.
var a = [[1, 2, 3], [4, 5, 6]];
# b is identical to a, the literal tensor is implicitly reshaped: defining new
# variables is the way to reshape tensors (element count must match).
var b<2, 3> = [1, 2, 3, 4, 5, 6];
# transpose() and print() are the only builtin, the following will transpose
# a and b and perform an element-wise multiplication before printing the result.
print(transpose(a) * transpose(b));
}