June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
8
Task/Entropy/Common-Lisp/entropy-2.lisp
Normal file
8
Task/Entropy/Common-Lisp/entropy-2.lisp
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
(defun entropy (string &aux (length (length string)))
|
||||
(declare (type string string))
|
||||
(let ((table (make-hash-table)))
|
||||
(loop for char across string
|
||||
do (incf (gethash char table 0)))
|
||||
(- (loop for freq being each hash-value in table
|
||||
for freq/length = (/ freq length)
|
||||
sum (* freq/length (log freq/length 2))))))
|
||||
Loading…
Add table
Add a link
Reference in a new issue