daily pastebin goal
77%
SHARE
TWEET

Untitled

a guest Jan 23rd, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (defun percentage-lineariser (x)
  2.   "Converts a percentage form into a more linear format. For example:
  3.  4/5 ->  80% -> -0.25
  4.  3/2 -> 150% ->  0.5
  5.  2/1 -> 200% ->  1.0
  6.  1/2 ->  50% -> -1.0
  7. This format is easier to work with difference-judging strategies such as
  8. EXPONENTIAL-MOVING-AVERAGE-STRATEGY. This function is undefined for negative
  9. and zero values."
  10.   (assert (plusp x) (x)
  11.           "Percentage must be positive")
  12.   (cond
  13.     ((> x 1) (1- x))
  14.     ((= x 1) 0)
  15.     ((< x 1) (- 1 (/ x)))))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top