Function: eshell-for-iterate

eshell-for-iterate is a byte-compiled function defined in esh-cmd.el.gz.

Signature

(eshell-for-iterate &rest ARGS)

Documentation

Iterate over the elements of each sequence in ARGS.

If ARGS is not a sequence, treat it as a list of one element.

Source Code

;; Defined in /usr/src/emacs/lisp/eshell/esh-cmd.el.gz
(iter-defun eshell-for-iterate (&rest args)
  "Iterate over the elements of each sequence in ARGS.
If ARGS is not a sequence, treat it as a list of one element."
  (dolist (arg args)
    (when (eshell--range-string-p arg)
      (setq arg (eshell--string-to-range arg)))
    (cond
     ((eshell-range-p arg)
      (let ((i (eshell-range-begin arg))
            (end (eshell-range-end arg)))
        ;; NOTE: We could support unbounded ranges here, but those
        ;; aren't very easy to use in Eshell yet.  (We'd need something
        ;; like the "break" statement for "for" loops.)
        (cl-assert (and i end))
        (while (< i end)
          (iter-yield i)
          (incf i))))
     ((stringp arg)
      (iter-yield arg))
     ((listp arg)
      (dolist (i arg) (iter-yield i)))
     ((arrayp arg)
      (dotimes (i (length arg)) (iter-yield (aref arg i))))
     (t
      (iter-yield arg)))))