Learn Juno through practical code examples
A classic recursive algorithm that showcases Juno's explicit type casting system. Notice how we cast between int and uint — Juno requires explicit conversions, preventing subtle bugs from implicit type coercion.
import Io;
uint fib(int n) {
if (n < 2) {
return uint<n>;
}
return fib(n-1) + fib(n-2);
}
void main() {
int n = 6;
Io.println("fib("^^string<n>^^") = "^^string<fib(n)>);
}
Key features demonstrated:
uint<n> and string<n> show Juno's strict type system^^ operator joins strings togetherimport Io; gives access to I/O functionsOutput:
fib(6) = 8
I'm working on adding more examples to showcase Juno's features. Check back soon for:
Want to contribute an example? Check out our GitHub repository!