1
0
Fork 0
forked from fun/fun

Some more stdlib fun and example code and cosmetic changes. (0.38.15)

This commit is contained in:
Johannes Findeisen 2026-02-19 21:50:24 +01:00
commit 9016b207b8
12 changed files with 330 additions and 4 deletions

43
examples/match.fun Executable file
View file

@ -0,0 +1,43 @@
#!/usr/bin/env fun
/*
* This file is part of the Fun programming language.
* https://fun-lang.xyz/
*
* Copyright 2026 Johannes Findeisen
* Licensed under the terms of the Apache-2.0 license.
* https://opensource.org/license/apache-2-0
*
* Added: 2026-02-19
*/
/*
* Demonstrates dynamic match() helper.
*/
#include <utils/option.fun>
print("-- match-like with numbers --")
x = 0
if (x == -1)
print("minus one")
else if (x == 0)
print("zero")
else if (x > 0)
print("positive: " + to_string(x))
else
print("negative: " + to_string(x))
print("-- match-like with Option --")
o1 = some(42)
o2 = none()
if is_some(o1)
print("Some(" + to_string(unwrap(o1)) + ")")
else
print("None")
if is_some(o2)
print("Some(" + to_string(unwrap(o2)) + ")")
else
print("None")