Skip to main content

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

ModulePurposeKey Functions
SystemI/O, process controlPrint(), Exit()
MathMathematical functionssqrt(), sin(), cos(), pow()
IOFile operationsReadFile(), WriteFile()
TimeTimestamps, timingNow(), Elapsed()
RandomRandom numbersRandom(), Range()
TensorMulti-dimensional arraysRandom(), Ones(), Zeros()
NNNeural networksSelfTest(), 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);
}

Next Steps