[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dash e07cef6 196/426: Adding -first-item and -last-item
From: |
Phillip Lord |
Subject: |
[elpa] externals/dash e07cef6 196/426: Adding -first-item and -last-item. [magnars/dash.el#17] |
Date: |
Tue, 04 Aug 2015 19:37:41 +0000 |
branch: externals/dash
commit e07cef640bf48e5adaf58e08aed5f6c694dddc98
Author: Wilfred Hughes <address@hidden>
Commit: Wilfred Hughes <address@hidden>
Adding -first-item and -last-item. [magnars/dash.el#17]
`-first-item` is a trivial alias to `car`, so I used `defalias` so
there isn't the additional overhead of a function call. This has
broken `create_docs.sh`.
It seems that `defexamples` expects `symbol-function` to return an
elisp function definition, but `car` is implemented in C.
---
dash.el | 7 +++++++
dev/examples.el | 8 ++++++++
2 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/dash.el b/dash.el
index 31e9a83..1107c21 100644
--- a/dash.el
+++ b/dash.el
@@ -27,6 +27,13 @@
;;; Code:
+(defalias '-first-item 'car
+ "Returns the first item of LIST, or nil on an empty list.")
+
+(defun -last-item (list)
+ "Returns the first item of LIST, or nil on an empty list."
+ (car (last list)))
+
(defmacro !cons (car cdr)
"Destructive: Sets CDR to the cons of CAR and CDR."
`(setq ,cdr (cons ,car ,cdr)))
diff --git a/dev/examples.el b/dev/examples.el
index e035320..2f13ae1 100644
--- a/dev/examples.el
+++ b/dev/examples.el
@@ -9,6 +9,14 @@
(defun square (num) (* num num))
(defun three-letters () '("A" "B" "C"))
+(defexamples -first-item
+ (-first-item '(1 2 3)) => 1
+ (-first-item nil => nil))
+
+(defexamples -last-item
+ (-last-item '(1 2 3)) => 3
+ (-last-item nil => nil))
+
(defexamples -map
(-map (lambda (num) (* num num)) '(1 2 3 4)) => '(1 4 9 16)
(-map 'square '(1 2 3 4)) => '(1 4 9 16)
- [elpa] externals/dash de67c4b 188/426: Add `-sort`, (continued)
- [elpa] externals/dash de67c4b 188/426: Add `-sort`, Phillip Lord, 2015/08/04
- [elpa] externals/dash 962e5b8 187/426: Merge pull request #33 from Fuco1/reduce-r, Phillip Lord, 2015/08/04
- [elpa] externals/dash d556884 186/426: Add reduce-r, the right associative variant of reduce, Phillip Lord, 2015/08/04
- [elpa] externals/dash 12291f3 191/426: Add -product function., Phillip Lord, 2015/08/04
- [elpa] externals/dash ff3d7bd 190/426: Add -sum function., Phillip Lord, 2015/08/04
- [elpa] externals/dash 8f9fca3 177/426: Merge pull request #30 from shosti/insert-at-opt, Phillip Lord, 2015/08/04
- [elpa] externals/dash 7e41bed 192/426: Merge pull request #35 from rejeep/sum-and-product, Phillip Lord, 2015/08/04
- [elpa] externals/dash 3226100 194/426: Indent according to emacs lisp standard, Phillip Lord, 2015/08/04
- [elpa] externals/dash 9f156a6 193/426: Release 1.5.0, Phillip Lord, 2015/08/04
- [elpa] externals/dash a3faf7c 183/426: Release 1.3.2, Phillip Lord, 2015/08/04
- [elpa] externals/dash e07cef6 196/426: Adding -first-item and -last-item. [magnars/dash.el#17],
Phillip Lord <=
- [elpa] externals/dash 50659cc 189/426: Release 1.4.0, Phillip Lord, 2015/08/04
- [elpa] externals/dash 4164908 197/426: Add -min, -max, -min-by and -max-by., Phillip Lord, 2015/08/04
- [elpa] externals/dash 2b20088 195/426: Add -juxt, Phillip Lord, 2015/08/04
- [elpa] externals/dash a3b2fdb 198/426: Merge pull request #38 from rejeep/min-and-max, Phillip Lord, 2015/08/04
- [elpa] externals/dash 22d2c2d 199/426: Release 1.6.0, Phillip Lord, 2015/08/04
- [elpa] externals/dash b0ff280 205/426: Updating docs--signature to handle aliases and subrs, Phillip Lord, 2015/08/04
- [elpa] externals/dash 506401e 203/426: Merge pull request #39 from Fuco1/rotate, Phillip Lord, 2015/08/04
- [elpa] externals/dash 5b5dab5 200/426: Fix typo, Phillip Lord, 2015/08/04
- [elpa] externals/dash 9bd656e 202/426: Add -rotate, Phillip Lord, 2015/08/04
- [elpa] externals/dash 970728e 201/426: Actually update README :P, Phillip Lord, 2015/08/04