mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-25 22:34:56 +00:00
Added official examples from github.com/modular/modular: - gpu-intro, gpu-functions, gpu-block-and-warp (GPU programming) - layout_tensor, layouts (tensor operations) - life (Conway's Game of Life) - operators (custom operators) - process (subprocess handling) - python-interop (Python integration) - testing (unit test patterns) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implementing operators for a custom Mojo type
This directory contains an example of implementing operators for a custom Mojo
struct named Complex, which represents a single complex number. The
my_complex.mojo module defines the Complex struct, and main.mojo is a
program that imports the module and shows examples of applying the operators to
instances of the Complex struct. The test_my_complex.mojo file is a set of
unit tests using the Mojo testing
framework.
Refer to An example of implementing operators for a custom
type
in the Mojo manual for a complete
explanation of the implementation of the Complex type.
If you have Pixi installed, you can execute the example by running the following command:
pixi run mojo main.mojo
You can run the unit tests by running the following command:
pixi run test