File path refactoring. No code changes. (0.37.51)
This commit is contained in:
parent
2fa8f8653e
commit
db68b30d5b
27 changed files with 0 additions and 0 deletions
36
examples/math/math_ceil.fun
Executable file
36
examples/math/math_ceil.fun
Executable file
|
|
@ -0,0 +1,36 @@
|
|||
#!/usr/bin/env fun
|
||||
|
||||
/*
|
||||
* This file is part of the Fun programming language.
|
||||
* https://fun-lang.xyz/
|
||||
*
|
||||
* Copyright 2026 Johannes Findeisen <you@hanez.org>
|
||||
* Licensed under the terms of the Apache-2.0 license.
|
||||
* https://opensource.org/license/apache-2-0
|
||||
*
|
||||
* Added: 2026-01-03
|
||||
*/
|
||||
|
||||
// Demo of C99-like ceil(x)
|
||||
|
||||
print("=== math ceil demo start ===")
|
||||
|
||||
print("ceil(3.2) -> " + to_string(ceil(3.2))) // 4
|
||||
print("ceil(3.0) -> " + to_string(ceil(3.0))) // 3
|
||||
print("ceil(-3.2) -> " + to_string(ceil(-3.2))) // -3
|
||||
print("ceil(-3.0) -> " + to_string(ceil(-3.0))) // -3
|
||||
print("ceil(0.5) -> " + to_string(ceil(0.5))) // 1
|
||||
print("ceil(-0.5) -> " + to_string(ceil(-0.5))) // 0
|
||||
|
||||
print("=== math ceil demo end ===")
|
||||
|
||||
/* Expected output (values):
|
||||
=== math ceil demo start ===
|
||||
ceil(3.2) -> 4
|
||||
ceil(3.0) -> 3
|
||||
ceil(-3.2) -> -3
|
||||
ceil(-3.0) -> -3
|
||||
ceil(0.5) -> 1
|
||||
ceil(-0.5) -> 0
|
||||
=== math ceil demo end ===
|
||||
*/
|
||||
30
examples/math/math_cos.fun
Executable file
30
examples/math/math_cos.fun
Executable file
|
|
@ -0,0 +1,30 @@
|
|||
#!/usr/bin/env fun
|
||||
|
||||
/*
|
||||
* This file is part of the Fun programming language.
|
||||
* https://fun-lang.xyz/
|
||||
*
|
||||
* Copyright 2026 Johannes Findeisen <you@hanez.org>
|
||||
* Licensed under the terms of the Apache-2.0 license.
|
||||
* https://opensource.org/license/apache-2-0
|
||||
*
|
||||
* Added: 2026-01-03
|
||||
*/
|
||||
|
||||
// Demo of cos(x)
|
||||
|
||||
print("=== math cos demo start ===")
|
||||
|
||||
print("cos(0) -> " + to_string(cos(0)))
|
||||
print("cos(3.14159265359) ~ pi -> " + to_string(cos(3.14159265359)))
|
||||
print("cos(1.57079632679) ~ pi/2 -> " + to_string(cos(1.57079632679)))
|
||||
|
||||
print("=== math cos demo end ===")
|
||||
|
||||
/* Expected output (approximate):
|
||||
=== math cos demo start ===
|
||||
cos(0) -> 1
|
||||
cos(3.14159265359) ~ pi -> -1
|
||||
cos(1.57079632679) ~ pi/2 -> 0
|
||||
=== math cos demo end ===
|
||||
*/
|
||||
34
examples/math/math_exp_log.fun
Executable file
34
examples/math/math_exp_log.fun
Executable file
|
|
@ -0,0 +1,34 @@
|
|||
#!/usr/bin/env fun
|
||||
|
||||
/*
|
||||
* This file is part of the Fun programming language.
|
||||
* https://fun-lang.xyz/
|
||||
*
|
||||
* Copyright 2026 Johannes Findeisen <you@hanez.org>
|
||||
* Licensed under the terms of the Apache-2.0 license.
|
||||
* https://opensource.org/license/apache-2-0
|
||||
*
|
||||
* Added: 2026-01-03
|
||||
*/
|
||||
|
||||
// Demo of exp(x), log(x), log10(x)
|
||||
|
||||
print("=== math exp/log demo start ===")
|
||||
|
||||
print("exp(0) -> " + to_string(exp(0)))
|
||||
print("log(1) -> " + to_string(log(1)))
|
||||
print("log10(1) -> " + to_string(log10(1)))
|
||||
print("exp(1) -> " + to_string(exp(1)))
|
||||
print("log(2.71828182846) ~ ln(e) -> " + to_string(log(2.71828182846)))
|
||||
|
||||
print("=== math exp/log demo end ===")
|
||||
|
||||
/* Expected output (approximate):
|
||||
=== math exp/log demo start ===
|
||||
exp(0) -> 1
|
||||
log(1) -> 0
|
||||
log10(1) -> 0
|
||||
exp(1) -> 2.718281828...
|
||||
log(2.71828182846) ~ ln(e) -> 1
|
||||
=== math exp/log demo end ===
|
||||
*/
|
||||
36
examples/math/math_floor.fun
Executable file
36
examples/math/math_floor.fun
Executable file
|
|
@ -0,0 +1,36 @@
|
|||
#!/usr/bin/env fun
|
||||
|
||||
/*
|
||||
* This file is part of the Fun programming language.
|
||||
* https://fun-lang.xyz/
|
||||
*
|
||||
* Copyright 2026 Johannes Findeisen <you@hanez.org>
|
||||
* Licensed under the terms of the Apache-2.0 license.
|
||||
* https://opensource.org/license/apache-2-0
|
||||
*
|
||||
* Added: 2026-01-03
|
||||
*/
|
||||
|
||||
// Demo of C99-like floor(x)
|
||||
|
||||
print("=== math floor demo start ===")
|
||||
|
||||
print("floor(3.7) -> " + to_string(floor(3.7))) // 3
|
||||
print("floor(3.0) -> " + to_string(floor(3.0))) // 3
|
||||
print("floor(-3.2) -> " + to_string(floor(-3.2))) // -4
|
||||
print("floor(-3.0) -> " + to_string(floor(-3.0))) // -3
|
||||
print("floor(0.5) -> " + to_string(floor(0.5))) // 0
|
||||
print("floor(-0.5) -> " + to_string(floor(-0.5))) // -1
|
||||
|
||||
print("=== math floor demo end ===")
|
||||
|
||||
/* Expected output (values):
|
||||
=== math floor demo start ===
|
||||
floor(3.7) -> 3
|
||||
floor(3.0) -> 3
|
||||
floor(-3.2) -> -4
|
||||
floor(-3.0) -> -3
|
||||
floor(0.5) -> 0
|
||||
floor(-0.5) -> -1
|
||||
=== math floor demo end ===
|
||||
*/
|
||||
32
examples/math/math_fmin_fmax.fun
Executable file
32
examples/math/math_fmin_fmax.fun
Executable file
|
|
@ -0,0 +1,32 @@
|
|||
#!/usr/bin/env fun
|
||||
|
||||
/*
|
||||
* This file is part of the Fun programming language.
|
||||
* https://fun-lang.xyz/
|
||||
*
|
||||
* Copyright 2026 Johannes Findeisen <you@hanez.org>
|
||||
* Licensed under the terms of the Apache-2.0 license.
|
||||
* https://opensource.org/license/apache-2-0
|
||||
*
|
||||
* Added: 2026-01-03
|
||||
*/
|
||||
|
||||
// Demo of fmin(x,y) / fmax(x,y) — float-aware min/max with C99 NaN handling
|
||||
|
||||
print("=== math fmin/fmax demo start ===")
|
||||
|
||||
print("fmin(3.2, 4) -> " + to_string(fmin(3.2, 4))) // 3.2
|
||||
print("fmax(3.2, 4) -> " + to_string(fmax(3.2, 4))) // 4
|
||||
print("fmin(-5, -2.5) -> " + to_string(fmin(-5, -2.5))) // -5
|
||||
print("fmax(-5, -2.5) -> " + to_string(fmax(-5, -2.5))) // -2.5
|
||||
|
||||
print("=== math fmin/fmax demo end ===")
|
||||
|
||||
/* Expected output:
|
||||
=== math fmin/fmax demo start ===
|
||||
fmin(3.2, 4) -> 3.2000000000000002
|
||||
fmax(3.2, 4) -> 4
|
||||
fmin(-5, -2.5) -> -5
|
||||
fmax(-5, -2.5) -> -2.5
|
||||
=== math fmin/fmax demo end ===
|
||||
*/
|
||||
35
examples/math/math_gcd_lcm.fun
Executable file
35
examples/math/math_gcd_lcm.fun
Executable file
|
|
@ -0,0 +1,35 @@
|
|||
#!/usr/bin/env fun
|
||||
|
||||
/*
|
||||
* This file is part of the Fun programming language.
|
||||
* https://fun-lang.xyz/
|
||||
*
|
||||
* Copyright 2026 Johannes Findeisen <you@hanez.org>
|
||||
* Licensed under the terms of the Apache-2.0 license.
|
||||
* https://opensource.org/license/apache-2-0
|
||||
*
|
||||
* Added: 2026-01-03
|
||||
*/
|
||||
|
||||
print("=== math gcd/lcm demo start ===")
|
||||
|
||||
print("gcd(48,18) -> " + to_string(gcd(48,18))) // 6
|
||||
print("gcd(0,5) -> " + to_string(gcd(0,5))) // 5
|
||||
print("gcd(-21,6) -> " + to_string(gcd(-21,6))) // 3
|
||||
|
||||
print("lcm(21,6) -> " + to_string(lcm(21,6))) // 42
|
||||
print("lcm(0,5) -> " + to_string(lcm(0,5))) // 0
|
||||
print("lcm(-4,6) -> " + to_string(lcm(-4,6))) // 12
|
||||
|
||||
print("=== math gcd/lcm demo end ===")
|
||||
|
||||
/* Expected output (values):
|
||||
=== math gcd/lcm demo start ===
|
||||
gcd(48,18) -> 6
|
||||
gcd(0,5) -> 5
|
||||
gcd(-21,6) -> 3
|
||||
lcm(21,6) -> 42
|
||||
lcm(0,5) -> 0
|
||||
lcm(-4,6) -> 12
|
||||
=== math gcd/lcm demo end ===
|
||||
*/
|
||||
38
examples/math/math_isqrt.fun
Executable file
38
examples/math/math_isqrt.fun
Executable file
|
|
@ -0,0 +1,38 @@
|
|||
#!/usr/bin/env fun
|
||||
|
||||
/*
|
||||
* This file is part of the Fun programming language.
|
||||
* https://fun-lang.xyz/
|
||||
*
|
||||
* Copyright 2026 Johannes Findeisen <you@hanez.org>
|
||||
* Licensed under the terms of the Apache-2.0 license.
|
||||
* https://opensource.org/license/apache-2-0
|
||||
*
|
||||
* Added: 2026-01-03
|
||||
*/
|
||||
|
||||
print("=== math isqrt demo start ===")
|
||||
|
||||
print("isqrt(-4) -> " + to_string(isqrt(-4))) // 0 (non-negative only)
|
||||
print("isqrt(0) -> " + to_string(isqrt(0))) // 0
|
||||
print("isqrt(1) -> " + to_string(isqrt(1))) // 1
|
||||
print("isqrt(2) -> " + to_string(isqrt(2))) // 1
|
||||
print("isqrt(3) -> " + to_string(isqrt(3))) // 1
|
||||
print("isqrt(4) -> " + to_string(isqrt(4))) // 2
|
||||
print("isqrt(15) -> " + to_string(isqrt(15))) // 3
|
||||
print("isqrt(16) -> " + to_string(isqrt(16))) // 4
|
||||
|
||||
print("=== math isqrt demo end ===")
|
||||
|
||||
/* Expected output (values):
|
||||
=== math isqrt demo start ===
|
||||
isqrt(-4) -> 0
|
||||
isqrt(0) -> 0
|
||||
isqrt(1) -> 1
|
||||
isqrt(2) -> 1
|
||||
isqrt(3) -> 1
|
||||
isqrt(4) -> 2
|
||||
isqrt(15) -> 3
|
||||
isqrt(16) -> 4
|
||||
=== math isqrt demo end ===
|
||||
*/
|
||||
36
examples/math/math_round.fun
Executable file
36
examples/math/math_round.fun
Executable file
|
|
@ -0,0 +1,36 @@
|
|||
#!/usr/bin/env fun
|
||||
|
||||
/*
|
||||
* This file is part of the Fun programming language.
|
||||
* https://fun-lang.xyz/
|
||||
*
|
||||
* Copyright 2026 Johannes Findeisen <you@hanez.org>
|
||||
* Licensed under the terms of the Apache-2.0 license.
|
||||
* https://opensource.org/license/apache-2-0
|
||||
*
|
||||
* Added: 2026-01-03
|
||||
*/
|
||||
|
||||
// Demo of C99-like round(x) — half away from zero
|
||||
|
||||
print("=== math round demo start ===")
|
||||
|
||||
print("round(3.2) -> " + to_string(round(3.2))) // 3
|
||||
print("round(3.5) -> " + to_string(round(3.5))) // 4
|
||||
print("round(3.8) -> " + to_string(round(3.8))) // 4
|
||||
print("round(-3.2) -> " + to_string(round(-3.2))) // -3
|
||||
print("round(-3.5) -> " + to_string(round(-3.5))) // -4
|
||||
print("round(-3.8) -> " + to_string(round(-3.8))) // -4
|
||||
|
||||
print("=== math round demo end ===")
|
||||
|
||||
/* Expected output (values):
|
||||
=== math round demo start ===
|
||||
round(3.2) -> 3
|
||||
round(3.5) -> 4
|
||||
round(3.8) -> 4
|
||||
round(-3.2) -> -3
|
||||
round(-3.5) -> -4
|
||||
round(-3.8) -> -4
|
||||
=== math round demo end ===
|
||||
*/
|
||||
32
examples/math/math_sign.fun
Executable file
32
examples/math/math_sign.fun
Executable file
|
|
@ -0,0 +1,32 @@
|
|||
#!/usr/bin/env fun
|
||||
|
||||
/*
|
||||
* This file is part of the Fun programming language.
|
||||
* https://fun-lang.xyz/
|
||||
*
|
||||
* Copyright 2026 Johannes Findeisen <you@hanez.org>
|
||||
* Licensed under the terms of the Apache-2.0 license.
|
||||
* https://opensource.org/license/apache-2-0
|
||||
*
|
||||
* Added: 2026-01-03
|
||||
*/
|
||||
|
||||
print("=== math sign demo start ===")
|
||||
|
||||
print("sign(-5) -> " + to_string(sign(-5))) // -1
|
||||
print("sign(0) -> " + to_string(sign(0))) // 0
|
||||
print("sign(7) -> " + to_string(sign(7))) // 1
|
||||
print("sign(-0.0) -> " + to_string(sign(-0.0))) // 0
|
||||
print("sign(3.14) -> " + to_string(sign(3.14))) // 1
|
||||
|
||||
print("=== math sign demo end ===")
|
||||
|
||||
/* Expected output (values):
|
||||
=== math sign demo start ===
|
||||
sign(-5) -> -1
|
||||
sign(0) -> 0
|
||||
sign(7) -> 1
|
||||
sign(-0.0) -> 0
|
||||
sign(3.14) -> 1
|
||||
=== math sign demo end ===
|
||||
*/
|
||||
30
examples/math/math_sin.fun
Executable file
30
examples/math/math_sin.fun
Executable file
|
|
@ -0,0 +1,30 @@
|
|||
#!/usr/bin/env fun
|
||||
|
||||
/*
|
||||
* This file is part of the Fun programming language.
|
||||
* https://fun-lang.xyz/
|
||||
*
|
||||
* Copyright 2026 Johannes Findeisen <you@hanez.org>
|
||||
* Licensed under the terms of the Apache-2.0 license.
|
||||
* https://opensource.org/license/apache-2-0
|
||||
*
|
||||
* Added: 2026-01-03
|
||||
*/
|
||||
|
||||
// Demo of sin(x)
|
||||
|
||||
print("=== math sin demo start ===")
|
||||
|
||||
print("sin(0) -> " + to_string(sin(0)))
|
||||
print("sin(1.57079632679) ~ pi/2 -> " + to_string(sin(1.57079632679)))
|
||||
print("sin(-1.57079632679) -> " + to_string(sin(-1.57079632679)))
|
||||
|
||||
print("=== math sin demo end ===")
|
||||
|
||||
/* Expected output (approximate):
|
||||
=== math sin demo start ===
|
||||
sin(0) -> 0
|
||||
sin(1.57079632679) ~ pi/2 -> 1
|
||||
sin(-1.57079632679) -> -1
|
||||
=== math sin demo end ===
|
||||
*/
|
||||
32
examples/math/math_sqrt.fun
Executable file
32
examples/math/math_sqrt.fun
Executable file
|
|
@ -0,0 +1,32 @@
|
|||
#!/usr/bin/env fun
|
||||
|
||||
/*
|
||||
* This file is part of the Fun programming language.
|
||||
* https://fun-lang.xyz/
|
||||
*
|
||||
* Copyright 2026 Johannes Findeisen <you@hanez.org>
|
||||
* Licensed under the terms of the Apache-2.0 license.
|
||||
* https://opensource.org/license/apache-2-0
|
||||
*
|
||||
* Added: 2026-01-03
|
||||
*/
|
||||
|
||||
// Demo of sqrt(x)
|
||||
|
||||
print("=== math sqrt demo start ===")
|
||||
|
||||
print("sqrt(0) -> " + to_string(sqrt(0)))
|
||||
print("sqrt(9) -> " + to_string(sqrt(9)))
|
||||
print("sqrt(2) -> " + to_string(sqrt(2)))
|
||||
print("sqrt(-1) -> " + to_string(sqrt(-1))) // NaN expected
|
||||
|
||||
print("=== math sqrt demo end ===")
|
||||
|
||||
/* Expected output (approximate):
|
||||
=== math sqrt demo start ===
|
||||
sqrt(0) -> 0
|
||||
sqrt(9) -> 3
|
||||
sqrt(2) -> 1.41421356...
|
||||
sqrt(-1) -> nan
|
||||
=== math sqrt demo end ===
|
||||
*/
|
||||
28
examples/math/math_tan.fun
Executable file
28
examples/math/math_tan.fun
Executable file
|
|
@ -0,0 +1,28 @@
|
|||
#!/usr/bin/env fun
|
||||
|
||||
/*
|
||||
* This file is part of the Fun programming language.
|
||||
* https://fun-lang.xyz/
|
||||
*
|
||||
* Copyright 2026 Johannes Findeisen <you@hanez.org>
|
||||
* Licensed under the terms of the Apache-2.0 license.
|
||||
* https://opensource.org/license/apache-2-0
|
||||
*
|
||||
* Added: 2026-01-03
|
||||
*/
|
||||
|
||||
// Demo of tan(x)
|
||||
|
||||
print("=== math tan demo start ===")
|
||||
|
||||
print("tan(0) -> " + to_string(tan(0)))
|
||||
print("tan(0.78539816339) ~ pi/4 -> " + to_string(tan(0.78539816339)))
|
||||
|
||||
print("=== math tan demo end ===")
|
||||
|
||||
/* Expected output (approximate):
|
||||
=== math tan demo start ===
|
||||
tan(0) -> 0
|
||||
tan(0.78539816339) ~ pi/4 -> 1
|
||||
=== math tan demo end ===
|
||||
*/
|
||||
36
examples/math/math_trunc.fun
Executable file
36
examples/math/math_trunc.fun
Executable file
|
|
@ -0,0 +1,36 @@
|
|||
#!/usr/bin/env fun
|
||||
|
||||
/*
|
||||
* This file is part of the Fun programming language.
|
||||
* https://fun-lang.xyz/
|
||||
*
|
||||
* Copyright 2026 Johannes Findeisen <you@hanez.org>
|
||||
* Licensed under the terms of the Apache-2.0 license.
|
||||
* https://opensource.org/license/apache-2-0
|
||||
*
|
||||
* Added: 2026-01-03
|
||||
*/
|
||||
|
||||
// Demo of C99-like trunc(x) — rounds toward zero
|
||||
|
||||
print("=== math trunc demo start ===")
|
||||
|
||||
print("trunc(3.7) -> " + to_string(trunc(3.7))) // 3
|
||||
print("trunc(3.0) -> " + to_string(trunc(3.0))) // 3
|
||||
print("trunc(-3.7) -> " + to_string(trunc(-3.7))) // -3
|
||||
print("trunc(-3.0) -> " + to_string(trunc(-3.0))) // -3
|
||||
print("trunc(0.5) -> " + to_string(trunc(0.5))) // 0
|
||||
print("trunc(-0.5) -> " + to_string(trunc(-0.5))) // 0
|
||||
|
||||
print("=== math trunc demo end ===")
|
||||
|
||||
/* Expected output (values):
|
||||
=== math trunc demo start ===
|
||||
trunc(3.7) -> 3
|
||||
trunc(3.0) -> 3
|
||||
trunc(-3.7) -> -3
|
||||
trunc(-3.0) -> -3
|
||||
trunc(0.5) -> 0
|
||||
trunc(-0.5) -> 0
|
||||
=== math trunc demo end ===
|
||||
*/
|
||||
Loading…
Add table
Add a link
Reference in a new issue