summaryrefslogtreecommitdiff
path: root/common.el
diff options
context:
space:
mode:
Diffstat (limited to 'common.el')
-rw-r--r--common.el20
1 files changed, 19 insertions, 1 deletions
diff --git a/common.el b/common.el
index 75fe201..0b3df31 100644
--- a/common.el
+++ b/common.el
@@ -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.