+2015-03-09 Nicolas Petton <nicolas@petton.fr>
+
+ * sequences.texi (seq-into): Add documentation for the new
+ seq-into function.
+
2015-03-03 Eli Zaretskii <eliz@gnu.org>
* processes.texi (Synchronous Processes): Update documentation of
@end example
@end defun
+@defun seq-into sequence type
+ This function converts the sequence @var{sequence} into a sequence
+of type @var{type}. @var{type} can be one of the following symbols:
+@code{vector}, @code{string} or @code{list}.
+
+@example
+@group
+(seq-into [1 2 3] 'list)
+@result{} (1 2 3)
+@end group
+@group
+(seq-into nil 'vector)
+@result{} []
+@end group
+@group
+(seq-into "hello" 'vector)
+@result{} [104 101 108 108 111]
+@end group
+@end example
+@end defun
+
+
@defmac seq-doseq (var sequence [result]) body@dots{}
@cindex sequence iteration
This macro is like @code{dolist}, except that @var{sequence} can be a list,
+2015-03-09 Nicolas Petton <nicolas@petton.fr>
+
+ * emacs-lisp/seq.el (seq-into): New function.
+ Bump seq.el version to 1.3.
+
2015-03-09 Dmitry Gutov <dgutov@yandex.ru>
* progmodes/ruby-mode.el (ruby-font-lock-keywords): Don't consider
;; Author: Nicolas Petton <nicolas@petton.fr>
;; Keywords: sequences
-;; Version: 1.2
+;; Version: 1.3
+;; Package: seq
;; Maintainer: emacs-devel@gnu.org
(if (listp seq)
(sort (seq-copy seq) pred)
(let ((result (seq-sort pred (append seq nil))))
- (seq--into result (type-of seq)))))
+ (seq-into result (type-of seq)))))
(defun seq-contains-p (seq elt &optional testfn)
"Return the first element in SEQ that equals to ELT.
seq)
(if (listp seq)
result
- (seq--into result (type-of seq)))))))
+ (seq-into result (type-of seq)))))))
-(defun seq--into (seq type)
- "Convert the sequence SEQ into a sequence of type TYPE."
+(defun seq-into (seq type)
+ "Convert the sequence SEQ into a sequence of type TYPE.
+TYPE can be one of the following symbols: vector, string or list."
(pcase type
(`vector (vconcat seq))
(`string (concat seq))
+2015-03-09 Nicolas Petton <nicolas@petton.fr>
+
+ * automated/seq-tests.el (test-seq-into): Add a test for seq-into.
+
2015-03-08 Dmitry Gutov <dgutov@yandex.ru>
* indent/ruby.rb: Add an example for bug#20026.
(should (equal (type-of (seq-reverse seq))
(type-of seq)))))
+(ert-deftest test-seq-into ()
+ (let* ((vector [1 2 3])
+ (list (seq-into vector 'list)))
+ (should (same-contents-p vector list))
+ (should (listp list)))
+ (let* ((list '(hello world))
+ (vector (seq-into list 'vector)))
+ (should (same-contents-p vector list))
+ (should (vectorp vector)))
+ (let* ((string "hello")
+ (list (seq-into string 'list)))
+ (should (same-contents-p string list))
+ (should (stringp string)))
+ (let* ((string "hello")
+ (vector (seq-into string 'vector)))
+ (should (same-contents-p string vector))
+ (should (stringp string)))
+ (let* ((list nil)
+ (vector (seq-into list 'vector)))
+ (should (same-contents-p list vector))
+ (should (vectorp vector))))
+
(provide 'seq-tests)
;;; seq-tests.el ends here