From 97bd23330dbd9954daced2e18ec5969e8ab81dfd Mon Sep 17 00:00:00 2001 From: Matus Goljer Date: Mon, 11 Sep 2017 15:11:07 +0200 Subject: [PATCH] Use lexical binding for -grade-up/down --- dash.el | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/dash.el b/dash.el index 5f6b8e5..c7759a1 100644 --- a/dash.el +++ b/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)))) + (->> (--map-indexed (cons it it-index) list) + (-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)))) + (->> (--map-indexed (cons it it-index) list) + (-sort (lambda (it other) (funcall comparator (car other) (car it)))) + (-map 'cdr))) (defvar dash--source-counter 0 "Monotonic counter for generated symbols.")