Skip to content

Instantly share code, notes, and snippets.

Created June 28, 2011 21:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/1052284 to your computer and use it in GitHub Desktop.
Save anonymous/1052284 to your computer and use it in GitHub Desktop.
;;------------------
;;agent_sim.core.clj
;;------------------
(ns agent_sim.core
(:gen-class)
(:use [agent_sim.config_handler :only [load-file]]))
(defn -main [& args]
;;config loading -->
(println "Loading config file/dir")
(load-file)
;;<-- config loading
;;starting sim -->
(println "Starting simulation")
;;<-- starting sim
;;ending sim -->
(println "Ending simulation")
;;<-- ending sim
)
;;------------------
;;agent_sim.config_handler.clj
;;------------------
(ns agent_sim.config_handler
(:use [clojure.contrib.duck-streams :only (read-lines)]))
;;refer to this for file reading: http://lethain.com/reading-file-in-clojure/
(defn process-file [file-name line-func line-acc]
(reduce line-func line-acc (read-lines file-name)))
(defn process-line [acc line]
(reduce #(assoc %1 %2 (+ get %1 %2 0) 1) acc (.split line " ")))
(defn load-file
"Loads the config.json or [config] directory within the directory containing this file"
[]
(prn (process-file "config_handler.clj" process-line 0)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment