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
one.rb ------------------- | |
Java::Main.thing = "thing1" | |
two.rb ------------------- | |
thing = Java::Main.thing | |
puts "thing: #{thing}" | |
puts "thing.class: #{thing.class}" |
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
one.rb ------------------------------------- | |
$GLOBAL = "ONE" | |
class Foo | |
def global | |
return "#{__FILE__}:GLOBAL = #{$GLOBAL}" | |
end | |
end | |
foo = Foo.new |
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
(defproject lein_issue "1.0.0-SNAPSHOT" | |
:description "FIXME: write" | |
:dependencies [[org.clojure/clojure "1.1.0"] | |
[org.clojure/clojure-contrib "1.1.0"] | |
[compojure "0.4.0-SNAPSHOT"] | |
[ring/ring-jetty-adapter "0.2.0"]] | |
:main lein_issue.core) |
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 lein_issue.core | |
(:use compojure.core | |
ring.adapter.jetty)) | |
(defroutes silly-routes | |
(ANY "*" [] | |
"<h1>Howdy</h1>")) | |
(run-jetty silly-routes {:port 8080}) |
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
Output when run from command line: | |
...................................................................... | |
Finished in 0.69600 seconds | |
70 examples, 0 failures | |
Output when run through eval-in-project: | |
...................................................................... | |
Finished in 0.69600 seconds |
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
bludgeon:speclj micahmartin$ lein javac | |
Exception in thread "main" java.lang.ClassCastException (NO_SOURCE_FILE:0) | |
at clojure.lang.Compiler.eval(Compiler.java:5440) | |
at clojure.lang.Compiler.eval(Compiler.java:5391) | |
at clojure.core$eval.invoke(core.clj:2382) | |
at clojure.main$eval_opt.invoke(main.clj:235) | |
at clojure.main$initialize.invoke(main.clj:254) | |
at clojure.main$script_opt.invoke(main.clj:270) | |
at clojure.main$main.doInvoke(main.clj:354) | |
at clojure.lang.RestFn.invoke(RestFn.java:458) |
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
bludgeon:speclj micahmartin$ lein jar | |
Exception in thread "main" java.lang.ExceptionInInitializerError (NO_SOURCE_FILE:1) | |
at clojure.lang.Compiler.eval(Compiler.java:5440) | |
at clojure.lang.Compiler.eval(Compiler.java:5415) | |
at clojure.lang.Compiler.eval(Compiler.java:5391) | |
at clojure.core$eval.invoke(core.clj:2382) | |
at clojure.main$eval_opt.invoke(main.clj:235) | |
at clojure.main$initialize.invoke(main.clj:254) | |
at clojure.main$null_opt.invoke(main.clj:279) | |
at clojure.main$main.doInvoke(main.clj:354) |
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 neighbors-of [cell] | |
(set (for [dx [-1 0 1] dy [-1 0 1] :when (not (= [dx dy] [0 0]))] | |
[(+ dx (first cell)) (+ dy (second cell))]))) | |
(defn alive? [[cell freqs] world] | |
(or (and (= 2 freqs) (contains? world cell)) (= 3 freqs))) | |
(defn tick [world] | |
(let [frequencies (frequencies (reduce #(concat %1 (neighbors-of %2)) [] world))] | |
(set (keys (filter #(alive? % world) frequencies))))) |
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
module PrimeFactors | |
def self.of(n) | |
factors = [] | |
divisor = 2 | |
while n > 1 | |
while n % divisor == 0 | |
factors << divisor | |
n /= divisor | |
end |
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 prime-factors) | |
(defn factors-of [n] | |
(loop [factors [] divisor 2 n n] | |
(if (<= n 1) | |
factors | |
(if (= 0 (rem n divisor)) | |
(recur | |
(conj factors divisor) | |
divisor |
OlderNewer