From 87d82ead963c24d84a4f6e417b96b9bf73d132bb Mon Sep 17 00:00:00 2001 From: Preston Pan Date: Sun, 8 Jan 2023 14:44:25 -0800 Subject: fix memory problem --- stdlib/math.nxs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 stdlib/math.nxs (limited to 'stdlib') 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)))) -- cgit