LoginSignup
10
11

More than 5 years have passed since last update.

Emacs25から標準添付されるseq.elを調べた

Posted at

Emacs25から新しくseq.elというものが導入されたみたいですね.

All functions are prefixed with "seq-".

全ての関数は seq- で始まるそうです.

All provided functions work on lists, strings and vectors.

ListとString,Vectorに統一的に使えるようです.
今までは適用する関数がまちまちだったのでありがたいですね.

Emacs25をインストールする

OSXでHomebrewをお使いなら以下のコマンドでインストールできます

brew install emacs --devel

インストールできたら,Emacsを起動してscratchバッファでバージョンを確認してみましょう.

(emacs-version)
"GNU Emacs 25.0.50.1 (x86_64-apple-darwin15.0.0, NS appkit-1404.13 Version 10.11.1 (Build 15B42))
 of 2015-12-04"

25.0 になってますね.

seqを試す

seq-で始まる関数は以下のようなものがあるようです

describe-functionseq- と打ったときの *Completions* バッファからコピーしました.
もっと上手に列挙する方法があれば教えてください)

seq--activate-font-lock-keywords    seq--count-successive   seq--elt-safe
seq--make-pcase-bindings    seq--make-pcase-patterns    seq--pcase-macroexpander
seq-concatenate     seq-contains    seq-copy
seq-count   seq-difference  seq-do
seq-doseq   seq-drop    seq-drop-while
seq-each    seq-elt     seq-empty-p
seq-every-p     seq-filter  seq-find
seq-group-by    seq-intersection    seq-into
seq-into-sequence   seq-length  seq-let
seq-map     seq-mapcat  seq-mapn
seq-max     seq-min     seq-partition
seq-position    seq-reduce  seq-remove
seq-reverse     seq-some    seq-sort
seq-subseq  seq-take    seq-take-while
seq-uniq

よくある seq-map を List,String,Vector へ試してみましょう.

;;; List
(seq-map (lambda (x) (+ x 1)) '(10 20 30))
(11 21 31)

;;; String
(seq-map (lambda (x) (format "++%c++" x)) "abcd")
("++a++" "++b++" "++c++" "++d++")

;;; Vector
(seq-map (lambda (x) (+ x 1)) [10 20 30])
(11 21 31)

全て同じ関数で扱えていますね.
今までリストを扱う外部ライブラリ dash.el でまかなっていた一部は seq.el で十分かもしれません.

10
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
11