Standard Library
Morph includes built-in modules for common operations. Depend on them with top-level module Name; lines (see Importing); the file’s own name comes from <Name>.mx, not from duplicating that module as a module line.
Available Modules
| Module | Purpose | Key Functions |
|---|---|---|
System | I/O, process control | Print(), Exit() |
Math | Mathematical functions | sqrt(), sin(), cos(), pow() |
IO | File operations | ReadFile(), WriteFile() |
Time | Timestamps, timing | Now(), Elapsed() |
Random | Random numbers | Random(), Range() |
Tensor | Multi-dimensional arrays | Random(), Ones(), Zeros() |
NN | Neural networks | SelfTest(), layers, optimizers |
Usage
module System;
module Math;
Init method() {
Print("Pi is: ");
Print(Math.PI);
}
Tensor Module
module Tensor;
Init method() {
t is Tensor<float>.Random(3, 3);
Print(t);
}
NN Module
module NN;
Init method() {
result is NN.SelfTest();
Print(result);
}