- (cl-defmethod seq-drop ((list list) n)
- "Optimized implementation of `seq-drop' for lists."
- (while (and list (> n 0))
- (setq list (cdr list)
- n (1- n)))
- list)
-
- (cl-defmethod seq-take ((list list) n)
- "Optimized implementation of `seq-take' for lists."
- (let ((result '()))
- (while (and list (> n 0))
- (setq n (1- n))
- (push (pop list) result))
- (nreverse result)))
-
- (cl-defmethod seq-drop-while (pred (list list))
- "Optimized implementation of `seq-drop-while' for lists."
- (while (and list (funcall pred (car list)))
- (setq list (cdr list)))
- list)
-
- (cl-defmethod seq-empty-p ((list list))
- "Optimized implementation of `seq-empty-p' for lists."
- (null list))
-
- \f
- (defun seq--make-pcase-bindings (args)
- "Return a list of bindings of the variables in ARGS to the elements of a sequence."
- (let ((bindings '())
- (index 0)
- (rest-marker nil))
- (seq-doseq (name args)
- (unless rest-marker
- (pcase name
- (`&rest
- (progn (push `(app (pcase--flip seq-drop ,index)
- ,(seq--elt-safe args (1+ index)))
- bindings)
- (setq rest-marker t)))
- (_
- (push `(app (pcase--flip seq--elt-safe ,index) ,name) bindings))))
- (setq index (1+ index)))
- bindings))
-
- (defun seq--make-pcase-patterns (args)
- "Return a list of `(seq ...)' pcase patterns from the argument list ARGS."
- (cons 'seq
- (seq-map (lambda (elt)
- (if (seqp elt)
- (seq--make-pcase-patterns elt)
- elt))
- args)))
-
- ;; TODO: make public?
- (defun seq--elt-safe (sequence n)
- "Return element of SEQUENCE at the index N.
+(cl-defmethod seq-drop ((list list) n)
+ "Optimized implementation of `seq-drop' for lists."
+ (while (and list (> n 0))
+ (setq list (cdr list)
+ n (1- n)))
+ list)
+
+(cl-defmethod seq-take ((list list) n)
+ "Optimized implementation of `seq-take' for lists."
+ (let ((result '()))
+ (while (and list (> n 0))
+ (setq n (1- n))
+ (push (pop list) result))
+ (nreverse result)))
+
+(cl-defmethod seq-drop-while (pred (list list))
+ "Optimized implementation of `seq-drop-while' for lists."
+ (while (and list (funcall pred (car list)))
+ (setq list (cdr list)))
+ list)
+
+(cl-defmethod seq-empty-p ((list list))
+ "Optimized implementation of `seq-empty-p' for lists."
+ (null list))
+
+\f
+(defun seq--make-pcase-bindings (args)
+ "Return a list of bindings of the variables in ARGS to the elements of a sequence."
+ (let ((bindings '())
+ (index 0)
+ (rest-marker nil))
+ (seq-doseq (name args)
+ (unless rest-marker
+ (pcase name
+ (`&rest
+ (progn (push `(app (pcase--flip seq-drop ,index)
+ ,(seq--elt-safe args (1+ index)))
+ bindings)
+ (setq rest-marker t)))
+ (_
+ (push `(app (pcase--flip seq--elt-safe ,index) ,name) bindings))))
+ (setq index (1+ index)))
+ bindings))
+
+(defun seq--make-pcase-patterns (args)
+ "Return a list of `(seq ...)' pcase patterns from the argument list ARGS."
+ (cons 'seq
+ (seq-map (lambda (elt)
+ (if (seqp elt)
+ (seq--make-pcase-patterns elt)
+ elt))
+ args)))
+
+;; TODO: make public?
+(defun seq--elt-safe (sequence n)
+ "Return element of SEQUENCE at the index N.