[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dash e07cef6 196/439: Adding -first-item and -last-item
From: |
Phillip Lord |
Subject: |
[elpa] externals/dash e07cef6 196/439: Adding -first-item and -last-item. [magnars/dash.el#17] |
Date: |
Tue, 04 Aug 2015 20:27:54 +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 1fc6679 185/439: Add -map-indexed to syntax highlighting, (continued)
- [elpa] externals/dash 1fc6679 185/439: Add -map-indexed to syntax highlighting, Phillip Lord, 2015/08/04
- [elpa] externals/dash 50659cc 189/439: Release 1.4.0, Phillip Lord, 2015/08/04
- [elpa] externals/dash ff3d7bd 190/439: Add -sum function., Phillip Lord, 2015/08/04
- [elpa] externals/dash 12291f3 191/439: Add -product function., Phillip Lord, 2015/08/04
- [elpa] externals/dash de67c4b 188/439: Add `-sort`, Phillip Lord, 2015/08/04
- [elpa] externals/dash 3226100 194/439: Indent according to emacs lisp standard, Phillip Lord, 2015/08/04
- [elpa] externals/dash 962e5b8 187/439: Merge pull request #33 from Fuco1/reduce-r, Phillip Lord, 2015/08/04
- [elpa] externals/dash d556884 186/439: Add reduce-r, the right associative variant of reduce, Phillip Lord, 2015/08/04
- [elpa] externals/dash 7e41bed 192/439: Merge pull request #35 from rejeep/sum-and-product, Phillip Lord, 2015/08/04
- [elpa] externals/dash 2b20088 195/439: Add -juxt, Phillip Lord, 2015/08/04
- [elpa] externals/dash e07cef6 196/439: Adding -first-item and -last-item. [magnars/dash.el#17],
Phillip Lord <=
- [elpa] externals/dash a3b2fdb 198/439: Merge pull request #38 from rejeep/min-and-max, Phillip Lord, 2015/08/04
- [elpa] externals/dash 4164908 197/439: Add -min, -max, -min-by and -max-by., Phillip Lord, 2015/08/04
- [elpa] externals/dash 22d2c2d 199/439: Release 1.6.0, Phillip Lord, 2015/08/04
- [elpa] externals/dash 5b5dab5 200/439: Fix typo, Phillip Lord, 2015/08/04
- [elpa] externals/dash 9f156a6 193/439: Release 1.5.0, Phillip Lord, 2015/08/04
- [elpa] externals/dash 970728e 201/439: Actually update README :P, Phillip Lord, 2015/08/04
- [elpa] externals/dash 9bd656e 202/439: Add -rotate, Phillip Lord, 2015/08/04
- [elpa] externals/dash b0ff280 205/439: Updating docs--signature to handle aliases and subrs, Phillip Lord, 2015/08/04
- [elpa] externals/dash 8b17154 204/439: Release 1.7.0, Phillip Lord, 2015/08/04
- [elpa] externals/dash 788573e 206/439: Merge pull request #36 from Wilfred/master, Phillip Lord, 2015/08/04