Skip to content

Instantly share code, notes, and snippets.

@emezeske
emezeske / spiral.clj
Created August 30, 2012 05:30 — forked from l1x/spiral.clj
(ns spiral)
(def matrix1 [[1 2 3][8 9 4][7 6 5]])
(def matrix2 [[1 2 3 4][12 13 14 5][11 16 15 6][10 9 8 7]])
(defn spiral-print [matrix result]
(let [[row & rows] (seq matrix)]
(if (seq rows)
(recur
(reverse (apply map vector rows))
(concat result row))
result)))