From 67ef9fbf276a3f1490910abfcb2f8387f0944a95 Mon Sep 17 00:00:00 2001 From: Darren Bane Date: Tue, 2 Nov 2021 13:22:02 +0000 Subject: Some Shen code --- shen/rms-defs.shen | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 shen/rms-defs.shen (limited to 'shen/rms-defs.shen') 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)) -- cgit 1.4.1-2-gfad0