Skip to content

Instantly share code, notes, and snippets.

@RSNara
Created January 1, 2017 23:34
Show Gist options
  • Save RSNara/a88c995a9035277f9f163f2ad87c639a to your computer and use it in GitHub Desktop.
Save RSNara/a88c995a9035277f9f163f2ad87c639a to your computer and use it in GitHub Desktop.
Silly adjacent implementation.
(defn adjacent [n coll]
(lazy-seq
(if-not (empty? coll)
(loop [i 0
element []
others coll]
(cond
(= i n) (cons element (adjacent n (rest coll)))
(empty? others) (list element)
:else (recur (inc i) (conj element (first others)) (rest others)))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment