thisago's blog


Array().reduce in Emacs Lisp

Might exist another solution for a JS-like reduce in Emacs Lisp, specially because it's essentially a functional programming language.

But the dolist does pretty much this:

(let ((my-array '(1 2 3 4)) ;; Define scoped variables
      (result '()))
  (dolist (item my-array result)
    (push item result)) ;; Adds `item' into `result'
  result) ;; Redundancy: return `result'
(4 3 2 1)

See more in Emacs: fn:dolist