Skip to content

Instantly share code, notes, and snippets.

View davidbody's full-sized avatar

David W. Body davidbody

View GitHub Profile
@davidbody
davidbody / pi.clj
Created August 11, 2011 18:26 — forked from bmabey/pi.clj
Calculate Pi in Clojure
(defn calculate-pi
"Calculates Pi using the approximation 4 * (1 - 1/3 + 1/5 - 1/7 + ...)"
[iterations]
(let [odd-numbers (filter odd? (iterate inc 1))]
(* 4.0
(apply + (map / (cycle [1.0 -1.0]) (take iterations odd-numbers))))))
(println "calculated pi =" (calculate-pi 100000))
(println "Math/PI =" Math/PI)
#!/bin/ruby
def combine_mp3_files(final_mp3)
`rm #{final_mp3}`
Dir.glob("*.mp3").sort.each do |file|
puts "#{file}"
`cat "#{file}" >> #{final_mp3}`
end
end