Skip to content

Instantly share code, notes, and snippets.

@jamiltron
Created July 15, 2011 00:00
Show Gist options
  • Save jamiltron/1083758 to your computer and use it in GitHub Desktop.
Save jamiltron/1083758 to your computer and use it in GitHub Desktop.
Flatten a List
;; Flatten a Sequence: Write a function which flattens a sequence.
(defn flat [n]
(let [x (first n)
xs (rest n)]
(cond
(empty? n) '()
(coll? x) (concat (flat x) (flat xs))
:else (cons x (flat xs)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment