Elisp: Sequence. First, Rest, Nth
Get nth
seq-elt-
get nth element. (index start at 0)
similar to
elt(seq-elt [0 1 2 3] 2) ;; 2
Get First, Rest
seq-first-
get the first element
(seq-first [3 4 5]) ;; 3 seq-rest-
return the rest elements.
(seq-rest (vector 3 4 5)) ;; [4 5] (seq-rest (list 3 4 5)) ;; (4 5) ;; demo that it return a new copy (let (xa xb) (setq xa (list 3 4 5)) (print (format "xa is %s" xa)) (setq xb (seq-rest xa)) (print (format "xb is %s" xb)) (pop xb) (print (format "xb is %s" xb)) (print (format "xa is %s" xa))) ;; "xa is (3 4 5)" ;; "xb is (4 5)" ;; "xb is (5)" ;; "xa is (3 4 5)"
Remove nth
seq-remove-at-position-
(seq-remove-at-position SEQUENCE N)remove item at index n.
(seq-remove-at-position [3 4 5] 1) ;; [3 5]