Created
December 10, 2009 23:17
-
-
Save tjennings/253799 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require ['clojure.contrib.shell-out :as 'shell]) | |
(def dir (second *command-line-args*)) | |
(defn as-seq [str] | |
(seq (.split str "\n"))) | |
(defn find-by-name [d n] (as-seq (shell/sh "find" "." "-name" n :dir d))) | |
(defn oggs [] (as-seq (shell/sh "find" "." "-name" "*.ogg" :dir dir))) | |
(defn indexed [coll] (map vector (iterate inc 0) coll)) | |
(defn map-with-index | |
[fun coll] | |
(map #(apply fun %) (indexed coll))) | |
(defn doprint | |
[coll] | |
(let [formatted (fn [idx st] (str "[" idx "] " st))] | |
(doseq [file (map-with-index formatted coll)] (println file)))) | |
;(defn directories | |
; [s] | |
; (map #(drop-last (.split % "/")))) | |
; | |
(doprint (find-by-name "./" "*.clj")) | |
;(directories (oggs)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment