# Morloc examples

> The programs the morloc.io playground opens, as plain text. Each page
> holds every file of one example and the command that builds it.

- [Hello World](https://morloc.io/examples/hello.md): String interpolation in pure morloc. Try: ./program hello World (1 file)
- [Composition](https://morloc.io/examples/composition.md): Chain functions with the . operator. Try: ./program reverseSort '[3,1,4,1,5,9,2,6]' (1 file)
- [Polyglot](https://morloc.io/examples/polyglot.md): Python map composed with C++ sort. Try: ./program addOneSorted '[5,2,8,1,9]' (1 file)
- [Records](https://morloc.io/examples/records.md): Structured data across languages. Try: ./program sumPoint '{"x": 3.5, "y": 2.1}' (1 file)
- [Foreign Source](https://morloc.io/examples/foreign-source.md): Import a Python function from a source file. Try: ./program greet World (2 files)
- [Multi-Module](https://morloc.io/examples/multi-module.md): Import from a local module. Try: ./program double 21 (2 files)
- [Binary Tree](https://morloc.io/examples/tree.md): A recursive sum type taken apart by pattern matching. Try: ./program invert '{"Node":[{"Node":["Leaf",1,"Leaf"]},2,"Leaf"]}' (1 file)
- [Effects](https://morloc.io/examples/effects.md): Declare an effect and sequence it with ! in a do-block. Try: ./program rollAdv (2 files)
- [TODO List](https://morloc.io/examples/todo.md): A pure core behind a generated CLI and a C++ ncurses TUI. Try: ./program add 'write the docs' -p 3 -t docs && ./program list -k (3 files)
- [K-mer Complexity](https://morloc.io/examples/kmers.md): A C++ std::map crosses into Python as a dict. Try: ./program rank '["GATTACAGATTACA","AAAAAAAAAAAAAA"]' (4 files)

Raw files are served at https://morloc.io/assets/examples/<id>/<file>.

To run one locally, install morloc
(https://morloc-project.github.io/docs/getting-started/installing.md),
put the files in a directory, and run:

```console
$ morloc make -o program main.loc
$ ./program -h
```
