import std/io import std/list fn fib :: n { if n < 2 { n } else { fib (n - 1) + fib (n - 2) } } // A tail-recursive loop must run in constant stack. fn count_to :: n acc { if n == 0 { acc } else { count_to (n - 1) (acc + 1) } } // Non-tail recursion 100k deep. fn build :: n { if n == 0 { [] } else { [n, ..build (n - 1)] } } pub fn main :: -> () / { io.println (show (1 + 2 * 3 - 4 / 2 % 3)) io.println (show (fib 20)) io.println (show (count_to 1_000_000 0)) io.println (show (list.length (build 100_000))) io.println (show (-7 / 2) <> " " <> show (-7 % 2)) io.println (show (1.5 * 2.0) <> " " <> show (10.0 / 4.0)) io.println if 3 >= 3 && !(2 > 3) || False { "logic ok" } else { "logic broken" } io.println ("con" <> "cat" <> show True) let total = list.range 1 10 |> list.map fn x { x * x } |> list.sum io.println ("sum of squares: " <> show total) } //> 5 //> 6765 //> 1000000 //> 100000 //> -3 -1 //> 3.0 2.5 //> logic ok //> concatTrue //> sum of squares: 385