Skip to content

Instantly share code, notes, and snippets.

@nasser
Created November 15, 2014 00:21
Show Gist options
  • Save nasser/c823bf081f3401158e93 to your computer and use it in GitHub Desktop.
Save nasser/c823bf081f3401158e93 to your computer and use it in GitHub Desktop.
triangle index functions
(defn tri-strip
([size] (tri-strip 0 size))
([start size]
(->> (range start (+ start size))
(partition 4 1)
(map (fn [[a b c d]] [a b c
c b d]))
flatten)))
(defn tri-fan
([size] (tri-fan 0 size))
([start size]
(->> (range (inc start) (+ start size))
(partition 2 1)
(map #(conj % start))
flatten)))
(defn tris
([size] (tris 0 size))
([start size]
(->> (range start (+ start size))
(partition 3)
flatten)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment