Created
January 19, 2011 02:38
-
-
Save sbastn/785591 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
(ns dependency-mgmt.core | |
(:require [clojure.contrib.string :as str])) | |
(def classes "A B C | |
B C E") | |
(def deps (ref {})) | |
(defn build-dependency-map [seq] | |
(let [name (keyword (str (first seq))) | |
dependents (map keyword (str/split #"\s" seq))] | |
(dosync (alter deps assoc {:name name :deps (rest dependents)})) | |
)) | |
(dosync (alter deps assoc :name "a" :deps "b")) | |
(str @deps) | |
(defn search [clazz dependency-map] | |
(let [name (dependency-map (keyword clazz) :name) | |
dependencies (dependency-map (keyword clazz) :deps)] | |
;; (swank.core/break) | |
(str name dependencies))) | |
(search :A (first (map build-dependency-map (str/split #"\n" classes)))) | |
((first (map build-dependency-map (str/split #"\n" classes))) :name) | |
(map build-dependency-map (str/split #"\n" classes)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment