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. 16
      dash.el

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

Loading…
Cancel
Save