Skip to content

Commit 26277bb

Browse files
author
Neil T. Dantam
committed
Use Alexandria MEAN and MEDIAN functions
1 parent c50a626 commit 26277bb

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

benchmark/src/calc.lisp

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -70,19 +70,6 @@
7070
(incf i))
7171
x))
7272

73-
(defun median (data)
74-
(let* ((n (length data))
75-
(n/2 (truncate (/ n 2))))
76-
(if (oddp n)
77-
(elt data n/2)
78-
(/ (+ (elt data n/2)
79-
(elt data (1- n/2)))
80-
2))))
81-
82-
(defun mean (data)
83-
(/ (reduce #'+ data)
84-
(length data)))
85-
8673
(defun nine-frac (n)
8774
(loop
8875
for i from 1 upto n
@@ -103,8 +90,8 @@
10390
(n (length data)))
10491
(let ((min (aref data 0))
10592
(max (aref data (1- n)))
106-
(median (median data))
107-
(mean (mean data))
93+
(median (alexandria:median data))
94+
(mean (alexandria:mean data))
10895
(nine-2 (nines-value 2 data))
10996
(nine-3 (nines-value 3 data))
11097
(nine-4 (nines-value 4 data))

0 commit comments

Comments
 (0)