[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] fix/group-by-write-out 1677338 02/14: Merge pull request #138 fro
From: |
Phillip Lord |
Subject: |
[elpa] fix/group-by-write-out 1677338 02/14: Merge pull request #138 from phillord/fix/group-by-write-out |
Date: |
Tue, 04 Aug 2015 19:45:03 +0000 |
branch: fix/group-by-write-out
commit 16773380cac81de04046053efc2753c74a7ef082
Merge: 19fbc24 45bd985
Author: Magnar Sveen <address@hidden>
Commit: Magnar Sveen <address@hidden>
Merge pull request #138 from phillord/fix/group-by-write-out
Reimplementation of --group-by.
---
dash.el | 44 +++++++++++++++++++-------------------------
1 files changed, 19 insertions(+), 25 deletions(-)
diff --git a/dash.el b/dash.el
index fa4057c..9788de6 100644
--- a/dash.el
+++ b/dash.el
@@ -915,31 +915,25 @@ other value (the body)."
(defmacro --group-by (form list)
"Anaphoric form of `-group-by'."
- (declare (debug (form form)))
- (let ((l (make-symbol "list"))
- (v (make-symbol "value"))
- (k (make-symbol "key"))
- (r (make-symbol "result")))
- `(let ((,l ,list)
- ,r)
- ;; Convert `list' to an alist and store it in `r'.
- (while ,l
- (let* ((,v (car ,l))
- (it ,v)
- (,k ,form)
- (kv (assoc ,k ,r)))
- (if kv
- (setcdr kv (cons ,v (cdr kv)))
- (push (list ,k ,v) ,r))
- (setq ,l (cdr ,l))))
- ;; Reverse lists in each group.
- (let ((rest ,r))
- (while rest
- (let ((kv (car rest)))
- (setcdr kv (nreverse (cdr kv))))
- (setq rest (cdr rest))))
- ;; Reverse order of keys.
- (nreverse ,r))))
+ (declare (debug t))
+ (let ((n (make-symbol "n"))
+ (k (make-symbol "k"))
+ (grp (make-symbol "grp")))
+ `(nreverse
+ (-map
+ (lambda (,n)
+ (cons (car ,n)
+ (nreverse (cdr ,n))))
+ (--reduce-from
+ (let* ((,k (,@form))
+ (,grp (assoc ,k acc)))
+ (if ,grp
+ (setcdr ,grp (cons it (cdr ,grp)))
+ (push
+ (list ,k it)
+ acc))
+ acc)
+ nil ,list)))))
(defun -group-by (fn list)
"Separate LIST into an alist whose keys are FN applied to the
- [elpa] branch fix/group-by-write-out created (now 36310ed), Phillip Lord, 2015/08/04
- [elpa] fix/group-by-write-out 7aec562 04/14: Merge pull request #140 from mijoharas/master, Phillip Lord, 2015/08/04
- [elpa] fix/group-by-write-out 45bd985 01/14: Reimplementation of --group-by., Phillip Lord, 2015/08/04
- [elpa] fix/group-by-write-out aa13c07 03/14: fixed typo in docs (first where it should be last, Phillip Lord, 2015/08/04
- [elpa] fix/group-by-write-out 63d2db9 05/14: make ->>'s second arg optional, Phillip Lord, 2015/08/04
- [elpa] fix/group-by-write-out 1677338 02/14: Merge pull request #138 from phillord/fix/group-by-write-out,
Phillip Lord <=
- [elpa] fix/group-by-write-out 89abffe 11/14: Make it explicit that not all VALS are evalled in -if-let*, Phillip Lord, 2015/08/04
- [elpa] fix/group-by-write-out 70caa37 06/14: Merge pull request #144 from cammsaul/thread_last_make_second_arg_optional, Phillip Lord, 2015/08/04
- [elpa] fix/group-by-write-out eadb265 13/14: Swap examples to better show how -some-> works, Phillip Lord, 2015/08/04
- [elpa] fix/group-by-write-out 36310ed 14/14: Added .elpaignore., Phillip Lord, 2015/08/04
- [elpa] fix/group-by-write-out c3cf98d 12/14: Add `-some->`, `-some->>`, and `-some-->` macros., Phillip Lord, 2015/08/04
- [elpa] fix/group-by-write-out e468937 09/14: Formatting, Phillip Lord, 2015/08/04
- [elpa] fix/group-by-write-out b88cfb7 10/14: Add dash prefix to epsilon variable., Phillip Lord, 2015/08/04
- [elpa] fix/group-by-write-out 1c2f43d 08/14: Add "See also" for the reduce family, Phillip Lord, 2015/08/04
- [elpa] fix/group-by-write-out 2aeeacb 07/14: Release 2.11.0, Phillip Lord, 2015/08/04