Examples¶
Gloat includes over 50 example programs in both Clojure and YAMLScript. These examples demonstrate the compilation pipeline and showcase what you can build.
All examples are available in the example/ directory of the
repository.
Running Examples¶
# Run a YAMLScript example
make run FILE=example/yamlscript/fizzbuzz.ys
# Run a Clojure example with arguments
make run FILE=example/clojure/factorial.clj a='10'
# Compile an example to binary
gloat example/yamlscript/dragon-curve.ys -o dragon
./dragon
Try Them¶
The best way to explore these examples is through the interactive demo:
- Click the Try Live Demo badge
- Wait for Codespaces to initialize (1-2 minutes)
- Select any example from the dropdown
- Click Compile to build to Wasm
- Click Run to execute in your browser
Or run them locally:
# Clone the repository
git clone https://github.com/gloathub/gloat
cd gloat
source .rc
# Run the demo server
make demo-server
# Or run individual examples
make run FILE=example/yamlscript/dragon-curve.ys
Contributing Examples¶
Have an interesting example to share? Contributions are welcome!
See the GitHub repository to submit examples via pull request.