This file contains hidden or 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 pom2proj | |
| (:require [clojure.xml :as xml] | |
| [clojure.zip :as zip] | |
| [clojure.java.io :as io] | |
| [clojure.data.zip.xml :as zx]) | |
| (:use [clojure.pprint :only [pprint]])) | |
| (defn- text-attrs | |
| [loc ks] | |
| (map (fn [k] |
This file contains hidden or 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
| ;; lein settings | |
| (defproject foo "1.0.0-SNAPSHOT" | |
| :description "Test App" | |
| :dependencies [[com.datomic/datomic "0.1.2678"] | |
| [frinj "0.1.2" :exclusions [org.clojure/clojure]]]) | |
| ;; load libs | |
| (use 'frinj.core 'frinj.calc) | |
| (frinj-init!) | |
| (use '[datomic.api :only (q db) :as d]) |
This file contains hidden or 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
| ;;; Written when pondering | |
| ;;; http://stackoverflow.com/questions/9086926/create-a-proxy-for-an-specific-instance-of-an-object-in-clojure | |
| (defmacro delegating-proxy [o class-and-ifaces ctor-args & impls] | |
| (let [oname (gensym)] | |
| (letfn [(delegating-impls [^java.lang.reflect.Method ms] | |
| (let [mname (symbol (.getName ^java.lang.reflect.Method (first ms))) | |
| arity-groups (partition-by #(count (.getParameterTypes ^java.lang.reflect.Method %)) ms) | |
| max-arity (max-key #(count (.getParameterTypes ^java.lang.reflect.Method %)) ms)] | |
| `(~mname |
This file contains hidden or 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 pharoh.core | |
| (:import #_(org.drools.compiler DrlParser) | |
| #_(org.drools.spi Consequence) | |
| (java.beans PropertyChangeSupport))) | |
| (definterface IBean | |
| (init []) | |
| (addPropertyChangeListener [pcl]) | |
| (removePropertyChangeListener [pcl])) |
This file contains hidden or 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 mars-rovers.core) | |
| (def dirs [:N :E :S :W]) | |
| (def move-dir {:N [0, 1] :E [1, 0] :S [0, -1] :W [-1, 0]}) | |
| (defn turn [dir dirs] | |
| (second | |
| (drop-while | |
| (complement #(= % dir)) |
This file contains hidden or 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 mars-rovers.core) | |
| (def dirs [:N :E :S :W]) | |
| (def move-dir {:N [0, 1] :E [1, 0] :S [0, -1] :W [-1, 0]}) | |
| (defn turn [dir dirs] | |
| (second | |
| (drop-while | |
| (complement #(= % dir)) |
This file contains hidden or 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
| (defn push-wrap [v wrap & args] | |
| (alter-var-root v #(with-meta (apply wrap % args) {::orig %}))) | |
| (defn pop-wrap [v] | |
| (alter-var-root v #(if-let [m (::orig (meta %))] m %))) | |
| (defn post [orig post-printer] | |
| (fn [& args] | |
| (let [rtn (apply orig args)] | |
| (post-printer orig rtn args) |
NewerOlder