Skip to content

Commit

Permalink
[magnars#200] Define setters for -first-item and -last-item
Browse files Browse the repository at this point in the history
  • Loading branch information
Matus Goljer committed Nov 8, 2016
1 parent 53e641c commit bcc74b5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions dash.el
Expand Up @@ -578,11 +578,15 @@ Alias: `-any'"
\(fn LIST)")

(gv-define-simple-setter -first-item setcar)

(defun -last-item (list)
"Return the last item of LIST, or nil on an empty list."
(declare (pure t) (side-effect-free t))
(car (last list)))

(gv-define-setter -last-item (val x) `(setcar (last ,x) ,val))

(defun -butlast (list)
"Return a list of all items in list except for the last."
;; no alias as we don't want magic optional argument
Expand Down

0 comments on commit bcc74b5

Please sign in to comment.