ruricolist / serapeum

Utilities beyond Alexandria
MIT License
415 stars 41 forks source link

Proposal: push-end #132

Closed mmontone closed 2 years ago

mmontone commented 2 years ago

Hi,

I use push-end quite a lot in my projects and think it would be a good addition to this library.

Lispworks has it: http://www.lispworks.com/documentation/lw71/LW/html/lw-808.htm

but I think other lisps don't.

This is my implementation, but there's better probably:

(defmacro push-end (obj place)
  "Push OBJ to the end of PLACE."
  `(if (null ,place)
       (setf ,place (list ,obj))
       (setf (cdr (last ,place))
         (cons ,obj nil))))

Thoughts?

mmontone commented 2 years ago

Thanks!! :D