Skip to content

Instantly share code, notes, and snippets.

(use '[clojure.contrib.macro-utils :only [macrolet]])
(defmacro defplugin [& body]
(let [g (gensym)]
(macrolet [(defcommand [docs words cmdkey & method-stuff]
`(do (dosync (doseq [word# ~words]
(assoc ~g word# {:cmd ~cmdkey :doc ~docs})))
(defmethod respond ~cmdkey ~@method-stuff)))]
`(let [~g (ref [])]
~@body
package mypkg;
public class Ugly {
public Ugly(){}
public String foo(boolean i) { return "bool: " + i; }
public String foo(Object o) { return "obj: " + o; }
}
user> (def u (foo.TestInterop2.))
#'user/u
; Copyright (c) Rich Hickey. All rights reserved.
; The use and distribution terms for this software are covered by the
; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
; which can be found in the file epl-v10.html at the root of this distribution.
; By using this software in any fashion, you are agreeing to be bound by
; the terms of this license.
; You must not remove this notice, or any other, from this software.
(set! *warn-on-reflection* true)
(ns hiredman.beans)
(defn -it [& _]
[[] (ref {})])
(defn setter [tis nam tat]
(dosync
(commute (.state tis)
assoc nam tat)))
(ns prolog
(:use clojure.contrib.def
clojure.contrib.str-utils
clojure.set
clojure.test))
(defvar facts (ref {:forward {} :back {}}) "Hashmap of clauses (forward and back references)")
(defn passmap
"Applies f to items only when (pred item) returns true."