Skip to content

Instantly share code, notes, and snippets.

@Wilfred
Last active December 14, 2015 03:19
Show Gist options
  • Save Wilfred/5020622 to your computer and use it in GitHub Desktop.
Save Wilfred/5020622 to your computer and use it in GitHub Desktop.
A tentative slice implementation
(defun --slice (list from &optional to)
"Return copy of LIST, starting from index FROM to index TO.
FROM or TO may be negative"
;; to defaults to the end of the list
(setq to (or to (length list)))
;; handle negative indices
(when (< from 0)
(setq from (mod from (length list))))
(when (< to 0)
(setq to (mod to (length list))))
(-take (- to from) (-drop from list)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment