aboutsummaryrefslogtreecommitdiff
path: root/environment.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-08-18 15:22:51 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-08-18 15:22:51 -0400
commita49870f810f19bef7e1dae1f61681c1682823d00 (patch)
treed00588be4f289c3036cdf2e7ad252f06663cd154 /environment.c
parentf4b04a1b8cd882e25fee592c819650c9b7e8566b (diff)
Add primality testing and next_prime()/prev_prime()
Diffstat (limited to 'environment.c')
-rw-r--r--environment.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/environment.c b/environment.c
index 7f7d7e7f..e13c9c13 100644
--- a/environment.c
+++ b/environment.c
@@ -110,6 +110,9 @@ env_t *new_compilation_unit(CORD *libname)
{"abs", "Int$abs", "func(x:Int)->Int"},
{"sqrt", "Int$sqrt", "func(x:Int)->Int"},
{"power", "Int$power", "func(base:Int,exponent:Int)->Int"},
+ {"is_prime", "Int$is_prime", "func(x:Int,reps=50)->Bool"},
+ {"next_prime", "Int$next_prime", "func(x:Int)->Int"},
+ {"prev_prime", "Int$prev_prime", "func(x:Int)->Int"},
)},
{"Int64", Type(IntType, .bits=TYPE_IBITS64), "Int64_t", "$Int64", TypedArray(ns_entry_t,
{"format", "Int64$format", "func(i:Int64, digits=0)->Text"},