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
describe "NIC-U" do | |
context "Fall conference" do | |
it "should be readable" do | |
"readable".should == "readable" | |
end | |
it { "readable".should == "readable"} | |
context "readable" do | |
it { should == "readable" } |
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
class Foo | |
attr_reader :name | |
def initialize(name) | |
@name = name | |
end | |
def method_missing(name, *args, &block) | |
return super unless name.to_s =~ /^go_/ | |
puts "Defining #{name}" | |
method = lambda { puts "hey #{@name}@#{object_id}, #{name.to_s.tr '_', ' '}" } |
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
(let [fibs (iterate (fn [[a b]] [b (+ a b)]) [0 1]) | |
just-the-fibs (take-while #(> 4e6 (apply max %)) fibs)] | |
(reduce (fn [sum [_ r]] (+ sum (if (even? r) r 0))) | |
0 | |
just-the-fibs)) |
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 nth-val [first-val step val-count] | |
(+ first-val (* step (dec val-count)))) | |
(defn arithmetic-series [first-val step val-count] | |
(let [last-val (nth-val first-val step val-count)] | |
(* val-count | |
(/ (+ first-val last-val) 2)))) | |
(defn arithmetic-series-of-multiples-less-than [ceiling] | |
(fn [val] |
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
(defstruct chopstick :id :holder) | |
(defstruct philosopher :name :left-stick :right-stick) | |
(defn make-chopstick [id] | |
(struct chopstick id (ref ""))) | |
(defn set-table [philosophers] | |
(let [stick-count (max 2 (count philosophers)) | |
stick-seq (map make-chopstick (range stick-count)) | |
stick-cycle (cycle (take stick-count stick-seq))] |
NewerOlder