improve slice

master
Avril 5 years ago
parent 8c04ed25aa
commit 93bedbc880
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -128,13 +128,19 @@
(index (+ max i) max) (index (+ max i) max)
(mod i max))) (mod i max)))
(defun slice (seq start end) (defun slice-list (seq start &optional (end -1))
"Like JS slice()?" "Like JS slice() for list"
(let ((start (index start (length seq))) (let ((start (index start (length seq)))
(end (index end (length seq)))) (end (index end (length seq))))
(rplacd (nthcdr end seq) nil) (rplacd (nthcdr end seq) nil)
(nthcdr start seq))) (nthcdr start seq)))
(defun slice (seq start &optional (end -1))
"Like JS slice()?"
(let ((start (index start (length seq)))
(end (index end (1+ (length seq)))))
(subseq seq start end)))
(defun flatten-top-level (li) (defun flatten-top-level (li)
"'( (1 2) 3 4 (5 6 7) (8) ((9 10))) -> ( 1 2 3 4 5 6 7 8 (9 10))" "'( (1 2) 3 4 (5 6 7) (8) ((9 10))) -> ( 1 2 3 4 5 6 7 8 (9 10))"
(mapcan #'(lambda (x) (mapcan #'(lambda (x)

Loading…
Cancel
Save