Is there a more ergonomic way to apply a function to a field in a struct in Elisp?
Say I have the following:
(cl-defstruct stack xs)
(defvar stack (make-stack :xs '(1 2 3 4 5)))
Is there an easy way to apply functions to the :xs field. I'd like an API like this:
(update-field :xs stack (lambda (xs)
(cl-map 'list #'1+ '(1 2 3 4 5))))
Does anyone know if this exists?
Update:
I'm looking for a way to DRY up the calls to (stack-xs stack) (see below). What I'm looking for is more similar to something like Map.update from Elixir.
(setf (stack-xs stack) (cl-map 'list #'1+ (stack-xs stack)))