You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
(define-module (deliberate borda)
|
|
|
|
#:use-module (deliberate utils)
|
|
|
|
#:export (borda-score))
|
|
|
|
|
|
|
|
(define (borda-score alternatives ranked)
|
|
|
|
;; Check whether all alternatives have been scored
|
|
|
|
(if (nil? alternatives)
|
|
|
|
'()
|
|
|
|
;; Check whether all ranked alternatives have been scored
|
|
|
|
(if (nil? ranked)
|
|
|
|
(let* ((n (length alternatives))
|
|
|
|
(score (/ (- n 1) 2)))
|
|
|
|
;; Assign average remaining score to all unranked alternatives
|
|
|
|
(map cons alternatives (const-list n score)))
|
|
|
|
;; Just use next rank
|
|
|
|
(let* ((alt (car ranked))
|
|
|
|
(remaining (delete alt alternatives)))
|
|
|
|
(cons (cons alt (length remaining))
|
|
|
|
(borda-score remaining (cdr ranked))))
|
|
|
|
)))
|