;; - `seq-do'
;; - `seq-p'
;; - `seq-subseq'
+;; - `seq-into-sequence'
;; - `seq-copy'
;; - `seq-into'
;;
TYPE must be one of following symbols: vector, string or list.
\n(fn TYPE SEQUENCE...)"
- (apply #'cl-concatenate type seqs))
+ (apply #'cl-concatenate type (seq-map #'seq-into-sequence seqs)))
+
+(cl-defgeneric seq-into-sequence (seq)
+ "Convert SEQ into a sequence.
+
+The default implementation is to signal an error if SEQ is not a
+sequence, specific functions should be implemented for new types
+of seq."
+ (unless (sequencep seq)
+ (error "Cannot convert %S into a sequence" seq))
+ seq)
(cl-defgeneric seq-into (seq type)
"Convert the sequence SEQ into a sequence of type TYPE.
(should (= (seq-min seq) 0))
(should (= (seq-max seq) 5))))
+(ert-deftest test-seq-into-sequence ()
+ (with-test-sequences (seq '(1 2 3))
+ (should (eq seq (seq-into-sequence seq)))
+ (should-error (seq-into-sequence 2))))
+
(provide 'seq-tests)
;;; seq-tests.el ends here