Use lexical binding for -grade-up/down

master
Matus Goljer 9 years ago committed by Basil L. Contovounesios
parent 558cd95367
commit 97bd23330d
No known key found for this signature in database
GPG Key ID: 205AB54A5D5D8CFF
  1. 12
      dash.el

@ -1758,21 +1758,17 @@ Note: `it' need not be used in each form."
"Grade elements of LIST using COMPARATOR relation, yielding a
permutation vector such that applying this permutation to LIST
sorts it in ascending order."
;; ugly hack to "fix" lack of lexical scope
(let ((comp `(lambda (it other) (funcall ',comparator (car it) (car other)))))
(->> (--map-indexed (cons it it-index) list)
(-sort comp)
(-map 'cdr))))
(-sort (lambda (it other) (funcall comparator (car it) (car other))))
(-map 'cdr)))
(defun -grade-down (comparator list)
"Grade elements of LIST using COMPARATOR relation, yielding a
permutation vector such that applying this permutation to LIST
sorts it in descending order."
;; ugly hack to "fix" lack of lexical scope
(let ((comp `(lambda (it other) (funcall ',comparator (car other) (car it)))))
(->> (--map-indexed (cons it it-index) list)
(-sort comp)
(-map 'cdr))))
(-sort (lambda (it other) (funcall comparator (car other) (car it))))
(-map 'cdr)))
(defvar dash--source-counter 0
"Monotonic counter for generated symbols.")

Loading…
Cancel
Save