Function: dash--match-vector-1

dash--match-vector-1 is a byte-compiled function defined in dash.el.

Signature

(dash--match-vector-1 MATCH-FORM SOURCE)

Documentation

Match MATCH-FORM against SOURCE.

MATCH-FORM is a vector. Each element of MATCH-FORM is either a symbol, which gets bound to the respective value in source or another match form which gets destructured recursively.

If second-from-last place in MATCH-FORM is the symbol &rest, the next element of the MATCH-FORM is matched against the tail of SOURCE, starting at index of the &rest symbol. This is conceptually the same as the (head . tail) match for improper lists, where dot plays the role of &rest.

SOURCE is a vector.

If the MATCH-FORM vector is shorter than SOURCE vector, only the (length MATCH-FORM) places are bound, the rest of the SOURCE is discarded.

Source Code

;; Defined in ~/.emacs.d/elpa/dash-20260221.1346/dash.el
(defun dash--match-vector-1 (match-form source)
  "Match MATCH-FORM against SOURCE.

MATCH-FORM is a vector.  Each element of MATCH-FORM is either a
symbol, which gets bound to the respective value in source or
another match form which gets destructured recursively.

If second-from-last place in MATCH-FORM is the symbol &rest, the
next element of the MATCH-FORM is matched against the tail of
SOURCE, starting at index of the &rest symbol.  This is
conceptually the same as the (head . tail) match for improper
lists, where dot plays the role of &rest.

SOURCE is a vector.

If the MATCH-FORM vector is shorter than SOURCE vector, only
the (length MATCH-FORM) places are bound, the rest of the SOURCE
is discarded."
  (let ((i 0)
        (l (length match-form))
        (re))
    (while (< i l)
      (let ((m (aref match-form i)))
        (push (cond
               ((and (symbolp m)
                     (eq m '&rest))
                (prog1 (dash--match
                        (aref match-form (1+ i))
                        `(substring ,source ,i))
                  (setq i l)))
               ((and (symbolp m)
                     ;; do not match symbols starting with _
                     (not (eq (aref (symbol-name m) 0) ?_)))
                (list (list m `(aref ,source ,i))))
               ((not (symbolp m))
                (dash--match m `(aref ,source ,i))))
              re)
        (setq i (1+ i))))
    (-flatten-n 1 (nreverse re))))