Last active
August 29, 2015 14:27
-
-
Save joastbg/8f87dcf8c0b7cc5f1dec to your computer and use it in GitHub Desktop.
Clojure snippets
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
| user=> (Long/toBinaryString (Double/doubleToLongBits 3.14)) | |
| "100000000001001000111101011100001010001111010111000010100011111" | |
| user=> (map #(println (apply str (drop 10 %1))) (map #(Long/toBinaryString (Double/doubleToLongBits %1)) (range 1 2 0.05))) | |
| 0000000000000000000000000000000000000000000000000000 | |
| 0000110011001100110011001100110011001100110011001101 | |
| 0001100110011001100110011001100110011001100110011010 | |
| 0010011001100110011001100110011001100110011001100111 | |
| 0011001100110011001100110011001100110011001100110100 | |
| 0100000000000000000000000000000000000000000000000001 | |
| 0100110011001100110011001100110011001100110011001110 | |
| 0101100110011001100110011001100110011001100110011011 | |
| 0110011001100110011001100110011001100110011001101000 | |
| 0111001100110011001100110011001100110011001100110101 | |
| 1000000000000000000000000000000000000000000000000010 | |
| 1000110011001100110011001100110011001100110011001111 | |
| 1001100110011001100110011001100110011001100110011100 | |
| 1010011001100110011001100110011001100110011001101001 | |
| 1011001100110011001100110011001100110011001100110110 | |
| 1100000000000000000000000000000000000000000000000011 | |
| 1100110011001100110011001100110011001100110011010000 | |
| 1101100110011001100110011001100110011001100110011101 | |
| 1110011001100110011001100110011001100110011001101010 | |
| 1111001100110011001100110011001100110011001100110111 | |
| (nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil) | |
| ;; ------------ | |
| (clojure.string/join " + " (map-indexed (fn [i v] (str v "_" i)) (take 10 (cycle "k")))) | |
| (str (clojure.string/join " + " (map-indexed (fn [i v] (str v "_" i)) (take 3 (cycle "k")))) " \\cdots " "k_{n-1}" "k_n") | |
| ;; ------------ | |
| (apply str (interpose ", " (take 3 (range)))) | |
| (interleave [:a :b :c] [1 2 3]) | |
| (zipmap [:a :b :c :d :e] [1 2 3 4 5]) | |
| ;; ------------ | |
| (use 'clojure.pprint) | |
| (print-table [{:a 1 :b 2 :c 3} {:b 5 :a 7 :c "dog"}]) | |
| ;; ------------ | |
| (import java.util.Date) | |
| (def ^:dynamic *now* (Date.)) | |
| (bean *now*) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment