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
package clojure.lang; | |
public interface ISetNode { | |
public static class Utils { | |
static public int bitpos(int hash, int shift){ | |
return 1 << mask(hash, shift); | |
} | |
static public int index(int bit, int bitmap){ | |
return Integer.bitCount(bitmap & (bit - 1)); |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<site> | |
<description url="http://clojure-dev.googlecode.com/svn/updatesite/"> | |
Clojuredev Update Site. Clojuredev is an Eclipse feature supporting the development of clojure code | |
</description> | |
<feature url="features/clojuredev.feature_0.0.20.jar" id="clojuredev.feature" version="0.0.20"> | |
<category name="Clojure Programming"/> | |
</feature> | |
<category-def name="Clojure Programming" label="Clojure Programming"> | |
<description> |
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
(grammar | |
[number [#{"0" "1" "2"}+] | |
expr #{number ["(" sum ")"]} | |
sum [prod ["+" prod]*] | |
prod [expr ["*" expr]*]) |
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 walk-out [customer] | |
(ref-set customer :outside)) | |
(defn wait [customer {q :queue}] | |
(alter q conj customer) | |
(ref-set customer :waiting)) | |
(defn sleeping? [barber] | |
(= :sleeping (ensure barber))) |
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
;; a better version of http://bestinclass.wordpress.com/2009/09/17/scala-vs-clojure-round-2-concurrency/ | |
(def empty-seats (ref 3)) | |
(def barber (agent 0)) | |
(defn debug [msg n] | |
(println msg (apply str (repeat (- 35 (count msg)) \space)) n) | |
(flush)) | |
(defn cut-hair [tally n] | |
(dosync (commute empty-seats inc)) |
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
;; philosophers must be initialized to 0 | |
(defn behave [qty id] | |
(when (pos? @rounds) (send-off *agent* behave id)) | |
(or | |
(dosync ; Initiate transaction | |
(when (and | |
(pos? @rounds) ; Is there more food? | |
(> 5 (rand-int 10)) ; Do I want to eat or think? | |
(got-forks? id)) ; Are both of my forks available? |
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
(require 'clojure.main) | |
(defn file-repl [filename] | |
(let [log (java.io.FileWriter. filename) | |
logout (fn [#^java.io.Writer out] | |
(proxy [java.io.Writer] [] | |
(write | |
([x] | |
(.write log x) | |
(.write out x)) |
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 board | |
(-> (vec (repeat 5 (vec (repeat 5 :off)))) | |
(assoc-in [0 0] :on) | |
(assoc-in [0 1] :on) | |
(assoc-in [1 2] :on))) | |
(defn neighbors-on [above [left _ right] below] | |
(count (filter #{:on} (concat above [left right] below)))) | |
(defn torus-windows [coll] |
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
<html> | |
<head> | |
<meta name="parent" content="layout"/> | |
</head> | |
<body> | |
<col1><div>ccol1</div></col1> | |
<col2><div>ccol2</div></col2> | |
<col3><div>ccol3</div></col3> | |
</body> | |
<html> |