My efforts to port http://www.youtube.com/watch?v=f6kdp27TYZs to Clojure.
func boring(msg string) {
for i := 0; ; i++ {
fmt.Println(msg, i)
time.Sleep(time.Second)
}
# Credit http://stackoverflow.com/a/2514279 | |
for branch in `git branch -r | grep -v HEAD`;do echo -e `git show --format="%ci %cr" $branch | head -n 1` \\t$branch; done | sort -r |
(ns monads | |
(:require clojure.set)) | |
(declare ^:dynamic return | |
^:dynamic bind) | |
(defn lift-inc [v] | |
(return (inc v))) | |
(defn m-add [mv n] |
(require '[clojure.core.async :as async :refer :all]) | |
(defn fake-search [kind] | |
(fn [query] | |
(Thread/sleep (int (* (java.lang.Math/random) 1000))) | |
(str kind " result for " query))) | |
(def web (fake-search "Web")) | |
(def image (fake-search "Image")) | |
(def video (fake-search "Video")) |
My efforts to port http://www.youtube.com/watch?v=f6kdp27TYZs to Clojure.
func boring(msg string) {
for i := 0; ; i++ {
fmt.Println(msg, i)
time.Sleep(time.Second)
}
Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.
# Put this in ~/.bash_profile | |
# https://gist.github.com/disq/42459b522836b25f30469b3acb5500bf | |
gcd() { | |
if [[ "$1" == "" || "$2" != "" ]]; then | |
echo "Usage: gcd <dir in gopath>" | |
return 1 | |
fi | |
FINDIN=${GOPATH}/src |