summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrsiddharth <s@ricketyspace.net>2016-12-30 02:02:08 +0000
committerrsiddharth <s@ricketyspace.net>2016-12-30 02:02:08 +0000
commitb1895584c721c78d8b91b0760b4c0c43f9730396 (patch)
tree0fec5361534aa7daddef2d00982146eaf0595012
parent767825a7fcd179e3777503e6b9f25fb84d0ca7ae (diff)
Add guile/taocp/utils/math.scm
-rw-r--r--guile/taocp/utils/math.scm17
1 files changed, 17 insertions, 0 deletions
diff --git a/guile/taocp/utils/math.scm b/guile/taocp/utils/math.scm
new file mode 100644
index 0000000..768d30d
--- /dev/null
+++ b/guile/taocp/utils/math.scm
@@ -0,0 +1,17 @@
+;;;; copyright 2016 rsiddharth <s@ricketyspace.net>
+;;;; under gnu general public license version 3 or higher.
+
+(define-module (taocp utils math)
+ #:export (compute-exp1-n))
+
+
+(define (compute-exp1-n fx n)
+ "Evaluate function FX for `x` equals 1 to N and return all results
+as a list
+
+Expression FX is a function that takes exactly one arugment.
+
+For instance `(lambda (x) (* x x))` is a valid FX.
+"
+ (cond ((= n 0) '())
+ (else (cons (fx n) (compute-exp1-n fx (1- n))))))