Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

please help decipher this lisp extract

(let ((g (* 2 (or (gethash word good) 0)))
      (b (or (gethash word bad) 0)))
   (unless (< (+ g b) 5)
     (max .01
          (min .99 (float (/ (min 1 (/ b nbad))
                             (+ (min 1 (/ g ngood))   
                                (min 1 (/ b nbad)))))))))
like image 816
EhudBRAK Avatar asked Mar 01 '26 03:03

EhudBRAK


1 Answers

What is the problem? It is almost plain english:

Let g be the value of word in the hashtable good (or 0 if not existent there) times 2

(let ((g (* 2 (or (gethash word good) 0)))

and b the value of word in the hashtable bad (or 0 if not existent there).

      (b (or (gethash word bad) 0)))

With this in mind, and under the presumption that the sum of g and b is not smaller than 5

   (unless (< (+ g b) 5)

return the maximum of either 0.01 or

     (max .01

the minimum of either 0.99 or

          (min .99 

b/nbad divided by the sum of b/nbad and g/ngood (as a float value, and those individual quotients should be at most 1).

               (float (/ (min 1 (/ b nbad))
                         (+ (min 1 (/ g ngood))   
                            (min 1 (/ b nbad)))))))))
like image 133
Svante Avatar answered Mar 02 '26 20:03

Svante



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!