diff options
author | Thanos Apollo <[email protected]> | 2024-02-08 18:15:21 +0200 |
---|---|---|
committer | Thanos Apollo <[email protected]> | 2024-02-08 18:15:21 +0200 |
commit | 49e797bbf0b14620408c3aa158551f7cac50adbe (patch) | |
tree | 237639597f579bdd742e3cfc7c0a368d6ee0153f /gnosis-algorithm.el | |
parent | 51be603b7bf819b34864403fb3b913186cbaf2bd (diff) |
gnosis-algorithm-e-factor: Refactor to use t or nil
Diffstat (limited to 'gnosis-algorithm.el')
-rw-r--r-- | gnosis-algorithm.el | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/gnosis-algorithm.el b/gnosis-algorithm.el index 02b9a87..11c99c8 100644 --- a/gnosis-algorithm.el +++ b/gnosis-algorithm.el @@ -84,16 +84,12 @@ The structure of the given date is (YEAR MONTH DAY)." (- (time-to-days (current-time)) (time-to-days given-date)))) -(defun gnosis-algorithm-e-factor (ef quality) - "Calculate new e-factor given existing EF and binary QUALITY, 0 or 1." - (cond - ((not (numberp quality)) - (error "Invalid argument passed to gnosis-algorithm-e-factor")) - ((= quality 0) ;; If the quality score is 0 (fail), decrease the ef by a small penalty - (max 1.3 (- ef (cadr gnosis-algorithm-ef)))) - ((= quality 1) ;; If the quality score is 1 (pass), increase the ef by a small reward - (+ ef (car gnosis-algorithm-ef))) - (t (error "Invalid quality score passed to gnosis-algorithm-e-factor")))) + +(defun gnosis-algorithm-e-factor (ef success) + "Calculate the new e-factor given existing EF and SUCCESS, either t or nil." + (pcase success + (`t (+ ef (car gnosis-algorithm-ef))) + (`nil (max 1.3 (- ef (cadr gnosis-algorithm-ef)))))) (cl-defun gnosis-algorithm-next-interval (&key last-interval review-num ef success failure-factor successful-reviews successful-reviews-c fails-c fails-t initial-interval) |