Skip to content

Instantly share code, notes, and snippets.

View craftybones's full-sized avatar

Srijayanth Sridhar craftybones

  • Bangalore, India
View GitHub Profile
(ns Player
(:gen-class))
(def xDirs {1 "E" 0 "" -1 "W"})
(def yDirs {1 "S" 0 "" -1 "N"})
(def offsets {1 inc 0 identity -1 dec})
(defn -main [& args]
(let [[lightX lightY initialTX initialTY] (repeatedly 4 read)
tX (atom initialTX)
tY (atom initialTY)]
if ([ "$LEIN_FAST_TRAMPOLINE" != "" ] || [ -r .lein-fast-trampoline ]) &&
[ -r project.clj ]; then
INPUTS="$@ $(cat project.clj) $LEIN_VERSION $(cat "$LEIN_HOME/profiles.clj")"
@craftybones
craftybones / 00_destructuring.md
Created June 4, 2016 06:11 — forked from john2x/00_destructuring.md
Clojure Destructuring Tutorial and Cheat Sheet

Clojure Destructuring Tutorial and Cheat Sheet

(Related blog post)

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.

Vectors

(defn prime-candidates
([] (lazy-seq (list* 2 3 (prime-candidates 1))))
([x] (lazy-seq (list* (dec (* x 6)) (inc (* x 6)) (prime-candidates (inc x))))))
(defn prime-candidates-less-than
[threshold]
(take-while (partial >= threshold) (prime-candidates)))
(defn is-prime?
[x]