From d3f257989f0120125ea9f4833c6c56efca4ce5da Mon Sep 17 00:00:00 2001 From: Andreas Gerler Date: Tue, 13 Nov 2018 12:49:26 +0100 Subject: [PATCH] update dash. Signed-off-by: Andreas Gerler --- .../dash-autoloads.el | 4 + .../dash-pkg.el | 2 +- .../dash.el | 101 +++++++++++++----- 3 files changed, 80 insertions(+), 27 deletions(-) rename elpa/{dash-20180726.1213 => dash-20180910.1856}/dash-autoloads.el (91%) rename elpa/{dash-20180726.1213 => dash-20180910.1856}/dash-pkg.el (55%) rename elpa/{dash-20180726.1213 => dash-20180910.1856}/dash.el (97%) diff --git a/elpa/dash-20180726.1213/dash-autoloads.el b/elpa/dash-20180910.1856/dash-autoloads.el similarity index 91% rename from elpa/dash-20180726.1213/dash-autoloads.el rename to elpa/dash-20180910.1856/dash-autoloads.el index 8bacbc83..c5e79028 100644 --- a/elpa/dash-20180726.1213/dash-autoloads.el +++ b/elpa/dash-20180910.1856/dash-autoloads.el @@ -11,6 +11,10 @@ (if (fboundp 'register-definition-prefixes) (register-definition-prefixes "dash" '("dash-" "-keep" "-butlast" "-non" "-only-some" "-zip" "-e" "->" "-a" "-gr" "-when-let" "-d" "-l" "-s" "-p" "-r" "-m" "-i" "-f" "-u" "-value-to-list" "-t" "--" "-c" "!cons" "!cdr"))) +;;;*** + +;;;### (autoloads nil nil ("dash-pkg.el") (0 0 0 0)) + ;;;*** ;; Local Variables: diff --git a/elpa/dash-20180726.1213/dash-pkg.el b/elpa/dash-20180910.1856/dash-pkg.el similarity index 55% rename from elpa/dash-20180726.1213/dash-pkg.el rename to elpa/dash-20180910.1856/dash-pkg.el index d239f068..29e71235 100644 --- a/elpa/dash-20180726.1213/dash-pkg.el +++ b/elpa/dash-20180910.1856/dash-pkg.el @@ -1,2 +1,2 @@ ;;; -*- no-byte-compile: t -*- -(define-package "dash" "20180726.1213" "A modern list library for Emacs" 'nil :commit "453c775e64e9ca61964b785b6d58ec00e4fec6d0" :keywords '("lists") :authors '(("Magnar Sveen" . "magnars@gmail.com")) :maintainer '("Magnar Sveen" . "magnars@gmail.com")) +(define-package "dash" "20180910.1856" "A modern list library for Emacs" 'nil :commit "6514359b8606a6a9a94068ccd601fcd6379d6584" :keywords '("lists") :authors '(("Magnar Sveen" . "magnars@gmail.com")) :maintainer '("Magnar Sveen" . "magnars@gmail.com")) diff --git a/elpa/dash-20180726.1213/dash.el b/elpa/dash-20180910.1856/dash.el similarity index 97% rename from elpa/dash-20180726.1213/dash.el rename to elpa/dash-20180910.1856/dash.el index 22b24632..ee67456a 100644 --- a/elpa/dash-20180726.1213/dash.el +++ b/elpa/dash-20180910.1856/dash.el @@ -4,7 +4,7 @@ ;; Author: Magnar Sveen ;; Version: 2.14.1 -;; Package-Version: 20180726.1213 +;; Package-Version: 20180910.1856 ;; Keywords: lists ;; This program is free software; you can redistribute it and/or modify @@ -126,6 +126,49 @@ Return nil, used for side-effects only." (put '-each-while 'lisp-indent-function 2) +(defmacro --each-r (list &rest body) + "Anaphoric form of `-each-r'." + (declare (debug (form body)) + (indent 1)) + (let ((v (make-symbol "vector"))) + ;; Implementation note: building vector is considerably faster + ;; than building a reversed list (vector takes less memory, so + ;; there is less GC), plus length comes naturally. In-place + ;; 'nreverse' would be faster still, but BODY would be able to see + ;; that, even if modification was reversed before we return. + `(let* ((,v (vconcat ,list)) + (it-index (length ,v)) + it) + (while (> it-index 0) + (setq it-index (1- it-index)) + (setq it (aref ,v it-index)) + ,@body)))) + +(defun -each-r (list fn) + "Call FN with every item in LIST in reversed order. + Return nil, used for side-effects only." + (--each-r list (funcall fn it))) + +(defmacro --each-r-while (list pred &rest body) + "Anaphoric form of `-each-r-while'." + (declare (debug (form form body)) + (indent 2)) + (let ((v (make-symbol "vector"))) + `(let* ((,v (vconcat ,list)) + (it-index (length ,v)) + it) + (while (> it-index 0) + (setq it-index (1- it-index)) + (setq it (aref ,v it-index)) + (if (not ,pred) + (setq it-index -1) + ,@body))))) + +(defun -each-r-while (list pred fn) + "Call FN with every item in reversed LIST while (PRED item) is non-nil. +Return nil, used for side-effects only." + (--each-r-while list (funcall pred it) (funcall fn it))) + (defmacro --dotimes (num &rest body) "Repeatedly executes BODY (presumably for side-effects) with symbol `it' bound to integers from 0 through NUM-1." (declare (debug (form body)) @@ -163,7 +206,7 @@ Return nil, used for side-effects only." "Return the result of applying FN to INITIAL-VALUE and the first item in LIST, then applying FN to that result and the 2nd item, etc. If LIST contains no items, return INITIAL-VALUE and -FN is not called. +do not call FN. In the anaphoric form `--reduce-from', the accumulated value is exposed as symbol `acc'. @@ -183,9 +226,9 @@ See also: `-reduce', `-reduce-r'" (defun -reduce (fn list) "Return the result of applying FN to the first 2 items in LIST, then applying FN to that result and the 3rd item, etc. If LIST -contains no items, FN must accept no arguments as well, and -reduce return the result of calling FN with no arguments. If -LIST has only 1 item, it is returned and FN is not called. +contains no items, return the result of calling FN with no +arguments. If LIST contains a single item, return that item +and do not call FN. In the anaphoric form `--reduce', the accumulated value is exposed as symbol `acc'. @@ -195,6 +238,11 @@ See also: `-reduce-from', `-reduce-r'" (-reduce-from fn (car list) (cdr list)) (funcall fn))) +(defmacro --reduce-r-from (form initial-value list) + "Anaphoric version of `-reduce-r-from'." + (declare (debug (form form form))) + `(--reduce-from ,form ,initial-value (reverse ,list))) + (defun -reduce-r-from (fn initial-value list) "Replace conses with FN, nil with INITIAL-VALUE and evaluate the resulting expression. If LIST is empty, INITIAL-VALUE is @@ -204,20 +252,18 @@ Note: this function works the same as `-reduce-from' but the operation associates from right instead of from left. See also: `-reduce-r', `-reduce'" - (if (not list) initial-value - (funcall fn (car list) (-reduce-r-from fn initial-value (cdr list))))) + (--reduce-r-from (funcall fn it acc) initial-value list)) -(defmacro --reduce-r-from (form initial-value list) - "Anaphoric version of `-reduce-r-from'." - (declare (debug (form form form))) - `(-reduce-r-from (lambda (&optional it acc) ,form) ,initial-value ,list)) +(defmacro --reduce-r (form list) + "Anaphoric version of `-reduce-r'." + (declare (debug (form form))) + `(--reduce ,form (reverse ,list))) (defun -reduce-r (fn list) "Replace conses with FN and evaluate the resulting expression. -The final nil is ignored. If LIST contains no items, FN must -accept no arguments as well, and reduce return the result of -calling FN with no arguments. If LIST has only 1 item, it is -returned and FN is not called. +The final nil is ignored. If LIST contains no items, return the +result of calling FN with no arguments. If LIST contains a single +item, return that item and do not call FN. The first argument of FN is the new item, the second is the accumulated value. @@ -226,15 +272,9 @@ Note: this function works the same as `-reduce' but the operation associates from right instead of from left. See also: `-reduce-r-from', `-reduce'" - (cond - ((not list) (funcall fn)) - ((not (cdr list)) (car list)) - (t (funcall fn (car list) (-reduce-r fn (cdr list)))))) - -(defmacro --reduce-r (form list) - "Anaphoric version of `-reduce-r'." - (declare (debug (form form))) - `(-reduce-r (lambda (&optional it acc) ,form) ,list)) + (if list + (--reduce-r (funcall fn it acc) list) + (funcall fn))) (defun -reductions-from (fn init list) "Return a list of the intermediate values of the reduction. @@ -250,7 +290,7 @@ See also: `-reductions', `-reductions-r', `-reduce-r'" See `-reduce' for explanation of the arguments. See also: `-reductions-from', `-reductions-r', `-reduce-r'" - (-reductions-from fn (car list) (cdr list))) + (and list (-reductions-from fn (car list) (cdr list)))) (defun -reductions-r-from (fn init list) "Return a list of the intermediate values of the reduction. @@ -266,7 +306,11 @@ See also: `-reductions-r', `-reductions', `-reduce'" See `-reduce-r' for explanation of the arguments. See also: `-reductions-r-from', `-reductions', `-reduce'" - (-reductions-r-from fn (-last-item list) (-butlast list))) + (when list + (let ((rev (reverse list))) + (--reduce-from (cons (funcall fn it (car acc)) acc) + (list (car rev)) + (cdr rev))))) (defmacro --filter (form list) "Anaphoric form of `-filter'. @@ -2268,6 +2312,10 @@ or with `-compare-fn' if that's non-nil." (--reduce (--take-while (and acc (equal (pop acc) it)) it) lists)) +(defun -common-suffix (&rest lists) + "Return the longest common suffix of LISTS." + (nreverse (apply #'-common-prefix (mapcar #'reverse lists)))) + (defun -contains? (list element) "Return non-nil if LIST contains ELEMENT. @@ -2862,6 +2910,7 @@ structure such as plist or alist." "-inits" "-tails" "-common-prefix" + "-common-suffix" "-contains?" "-contains-p" "-same-items?" -- 2.47.3