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 org.drewolson.test-dragon | |
(:use clojure.contrib.test-is org.drewolson.dragon) | |
(:gen-class)) | |
(deftest foo | |
(is (= 1 1))) | |
(defn -main [] | |
(run-tests 'org.drewolson.test-dragon) | |
(.flush *test-out*)) |
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
; updated for Clojure SVN 1309 | |
(defn parse-grid [s] | |
(vec (map (fn [line] (vec (map #(Integer. %) (.split line ",")))) | |
(.split s "\\s+")))) | |
(defn main [gridstr] | |
(let [costs (parse-grid gridstr) | |
size (count costs)] | |
(loop [min-sums (vec (replicate size (vec (replicate size nil)))) |
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 org.drewolson.dragon | |
(:gen-class | |
:extends javax.swing.JFrame)) | |
(defn -paint [this graphics] | |
(prn :paint-called) | |
(doto graphics | |
(.drawString "Hello, World" 20 20))) | |
(defn -main [] |
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
(defn bind-vec [state-map start-state [stroke & strokes] func force?] | |
(when-not force? | |
(let [old-val (get-in start-state [start-state stroke])] | |
(cond | |
(and (symbol? old-val) (not strokes)) | |
(throw (Exception. "New binding would be eclipsed by existing binding")) | |
(and (not (symbol? old-var)) strokes) | |
(throw (Exception. "Existing binding would eclipse new binding")) | |
(and (not (symbol? old-var)) (not strokes)) | |
(throw (Exception. "New binding would replace existing binding"))))) |
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
(def status "this is my status") | |
(def rdr (java.io.PushbackReader. (java.io.StringReader. status))) | |
(distinct | |
(loop [words []] | |
(let [word (read rdr false nil)] | |
(if (word) | |
(recur (conj words word)) | |
words)))) | |
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
(import '(java.awt Point Graphics Frame) '(java.awt.geom AffineTransform)) | |
(def minpoint (doto (Point.) (.setLocation 0 0))) | |
(def maxpoint (doto (Point.) (.setLocation 1000 1000))) | |
(defmacro branch [t & choices] | |
`(let [maxp# (.transform ~t maxpoint (Point.)) | |
minp# (.transform ~t minpoint (Point.))] | |
(if (zero? (.distance maxp# minp#)) | |
maxp# | |
(condp = (rand-int ~(count choices)) |
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 net.n01se.Tree | |
(:import (java.awt Point Graphics Frame Color) | |
(java.awt.geom AffineTransform)) | |
(:gen-class | |
:extends java.applet.Applet)) | |
;--- recursive fractal drawing framework --- | |
; define min and max points for the logical stage | |
(def minpoint (doto (Point.) (.setLocation 0 0))) |
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
(defn same-size [& cols] | |
(let [size (reduce max (map count cols))] | |
(apply interleave | |
(map #(concat % (replicate (- size (count %)) 0)) cols)))) | |
user=> (same-size [1 2] [3 4 5]) | |
(1 3 2 4 0 5) |
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
(import '(java.awt Point Graphics Frame) '(java.awt.geom AffineTransform)) | |
(def minpoint (doto (Point.) (.setLocation 0 0))) | |
(def maxpoint (doto (Point.) (.setLocation 1000 1000))) | |
(defmacro branch [t & choices] | |
(let [opt (gensym)] | |
`(let [maxp# (.transform ~t maxpoint (Point.)) | |
minp# (.transform ~t minpoint (Point.))] | |
(if (zero? (.distance maxp# minp#)) | |
maxp# |
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
(import '(javax.swing JFrame JPanel JScrollPane JTable SwingUtilities) | |
'(javax.swing.table AbstractTableModel DefaultTableCellRenderer) | |
'(java.awt Dimension GridLayout Font Color) | |
'(java.awt.event MouseAdapter) | |
'(java.sql DriverManager)) | |
(def table (JTable.)) | |
(SwingUtilities/invokeLater | |
(fn [] |
OlderNewer