This file contains hidden or 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 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 -1]) (take iterations odd-numbers)))))) | |
(println "calculated pi =" (calculate-pi 100000)) | |
(println "Math/PI =" Math/PI) |
This file contains hidden or 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 cljs-minimal.core | |
(:require [cljs.core.async :as async :refer [put! <! >! <!! >!! chan]]) | |
(:require-macros [cljs.core.async.macros :as m :refer [go]])) | |
(defn get-position [] | |
(let [out (chan) | |
geo (.-geolocation js/navigator)] | |
(.getCurrentPosition geo (fn [pos] (put! out pos))) | |
out)) |
This file contains hidden or 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 urls (array "http://a.tile.openstreetmap.org/${z}/${x}/${y}.png" | |
"http://b.tile.openstreetmap.org/${z}/${x}/${y}.png" | |
"http://c.tile.openstreetmap.org/${z}/${x}/${y}.png")) | |
(def OSM (js/OpenLayers.Layer.XYZ. "OSM (with buffer)" urls (extend-object! (js-obj) {"transitionEffect" "resize" | |
"buffer" 2 | |
"wrapDateLine" true | |
"sphericalMercator" true}))) | |
(def plot (js/OpenLayers.Map. (extend-object! (js-obj) {"div" "plot" |
NewerOlder