Skip to content

Instantly share code, notes, and snippets.

@alandipert
Created November 27, 2018 16:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alandipert/96a131694a8efbc08d0f589150f3236e to your computer and use it in GitHub Desktop.
Save alandipert/96a131694a8efbc08d0f589150f3236e to your computer and use it in GitHub Desktop.
(defn shape-with [shape xs]
(->> (reductions (fn [[a b] n]
((juxt take drop) n b))
[xs xs]
shape)
rest
(map first)))
(defun shape-with (shape xs)
(loop for n in shape
collect (subseq xs 0 n)
do (setq xs (nthcdr n xs))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment