diff options
author | JSDurand <mmemmew@gmail.com> | 2021-08-28 19:07:45 +0800 |
---|---|---|
committer | JSDurand <mmemmew@gmail.com> | 2021-08-28 19:07:45 +0800 |
commit | 30e4f3280bdbb82e10be0cf6a5dc68863b13fb80 (patch) | |
tree | d22d3b8e90d6a193b57ceef0da9e1cd90b289c1d | |
parent | d88aaabf6d40349c3d20ffa96fbba603e1075b04 (diff) |
* common.el (durand-take): Convenient function
-rw-r--r-- | common.el | 20 |
1 files changed, 19 insertions, 1 deletions
@@ -450,8 +450,26 @@ current line; negative ARG means to put the line upwards." (num)))) (insert "\n" line))))) +;;; A minor helper function + +;;;###autoload +(defun durand-take (n ls) + "Return the first N items of LS. +If the length of LS is less than N, then return the whole LS." + (cond + ((< (length ls) n) ls) + ((let ((i 0) result) + (while (< i n) + (cond + (ls + (setq result (cons (car ls) result)) + (setq ls (cdr ls)) + (setq i (1+ i))) + ((setq i n)))) + (reverse result))))) + (provide 'common) -;;; common.el ends here. +;; common.el ends here. |