Examples
Here are some small examples of ways to do various things in Roc.
NOTE: These examples use Roc alpha4 (stable Rust compiler). Some of the syntax is deprecated and will not work with the new Zig compiler. If you would like to experiment with the unstable Zig compiler, you can try this guide.
You can find the source code for all of these at github.com/roc-lang/examples
- Hello, World!
- FizzBuzz
- Basic Dict Usage
- Tuples
- Pattern Matching on Lists
- Error Handling Basic (Result)
- Error Handling Real World (Result)
?Operator Desugaring- Import Files
- Import from Directory
- Import Package from Module
- Multiple Roc Files
- JSON
- Hello, Webserver!
- All Syntax in 1 File
- Scripting
- Terminal Commands
- Sort Strings
- Random Numbers
- CLI Args Simple
- CLI Args File
- Safe Math
- Graph Traversal
- Parser
- Looping Effectful Functions
- Snake Game
- Record Builder
- Encoding & Decoding Abilities
- Custom Inspect
- Least Squares
- Towers of Hanoi
- Multi-line Comments
- Go Platform
- .NET Platform
- Elm Web App