原文地址:https://www.lujun9972.win/blog/2022/02/17/emacs-lisp中如何创建整数列表/index.html
emacs-lisp中提供了一堆 seq-*
函数对序列进行操作,但却缺少类似 Python 中的 range
函数那样的生成序列的函数。
在网上搜索了一下才知道 emacs-lisp 中是可以使用 number-sequence
来实现类似的功能的。
number-sequence is a compiled Lisp function in ‘subr.el’. (number-sequence FROM &optional TO INC) Probably introduced at or before Emacs version 22.1. Return a sequence of numbers from FROM to TO (both inclusive) as a list. INC is the increment used between numbers in the sequence and defaults to 1. So, the Nth element of the list is (+ FROM (* N INC)) where N counts from zero. TO is included only if there is an N for which TO = FROM + N * INC. If TO is nil or numerically equal to FROM, return (FROM). If INC is positive and TO is less than FROM, or INC is negative and T