about summary refs log tree commit diff stats
path: root/shen/rms-defs.shen
diff options
context:
space:
mode:
Diffstat (limited to 'shen/rms-defs.shen')
-rw-r--r--shen/rms-defs.shen20
1 files changed, 20 insertions, 0 deletions
diff --git a/shen/rms-defs.shen b/shen/rms-defs.shen
new file mode 100644
index 0000000..7839a17
--- /dev/null
+++ b/shen/rms-defs.shen
@@ -0,0 +1,20 @@
+(define mean
+  { (list number) --> number }
+  Xs -> (/ (sum Xs) (length Xs)))
+ 
+(define square
+  { number --> number }
+  X -> (* X X))
+ 
+(define rms
+  { (list number) --> number }
+  Xs -> (sqrt (mean (map (function square) Xs))))
+ 
+(define iota-h
+  { number --> number --> (list number) }
+  X X -> [X]
+  X Lim -> (cons X (iota-h (+ X 1) Lim)))
+ 
+(define iota
+  { number --> (list number) }
+  Lim -> (iota-h 1 Lim))