diff options
author | Preston Pan <preston@nullring.xyz> | 2023-01-08 14:44:25 -0800 |
---|---|---|
committer | Preston Pan <preston@nullring.xyz> | 2023-01-08 14:44:25 -0800 |
commit | 87d82ead963c24d84a4f6e417b96b9bf73d132bb (patch) | |
tree | 096e60118f6e62508db653d5102d85e77b8d73e9 /stdlib | |
parent | aa1dd020edb82f26dd5bc29378177cfcaa4c53ed (diff) |
fix memory problem
Diffstat (limited to 'stdlib')
-rw-r--r-- | stdlib/math.nxs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/stdlib/math.nxs b/stdlib/math.nxs new file mode 100644 index 0000000..f913d82 --- /dev/null +++ b/stdlib/math.nxs @@ -0,0 +1,20 @@ +;; some bootstrapping needed in order to obtain more complicated functions; +;; the power series requires a factorial and integer power function +(bind powi (lambda (x y) + (if (= y 1) + x + (* x (pow x (- y 1))) +))) +(bind factorial (lambda (n) + (if (= n 0) 1 (* n (factorial (print(- n 1))))))) + +;; complicated functions +(bind exp (lambda (x) x)) + +(bind ln (lambda (x) x)) + +(bind sin (lambda (x) x)) + +(bind cos (lambda (x) x)) + +(bind tan (lambda (x) (/ (sin x) (cos x)))) |