This file contains 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 test-app.core) | |
;; true | |
[(boolean 0) | |
(boolean "false") | |
(boolean '()) | |
;; false | |
(boolean nil) |
This file contains 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 test-app.core | |
(:require [clojure.pprint :refer [pprint]])) | |
(->> java.sql.ResultSet | |
(.getMethods) | |
(map method-sig) | |
(pprint)) |
This file contains 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
(partition-by #(mod % 3) (range 1 10)) | |
;;((1) (2) (3) (4) (5) (6) (7) (8) (9)) | |
(partition-by #(mod % 3) (mapcat (partial repeat 3) (range 1 10))) | |
;;((1 1 1) (2 2 2) (3 3 3) (4 4 4) (5 5 5) (6 6 6) (7 7 7) (8 8 8) (9 9 9)) | |
(group-by #(mod % 3) (range 1 10)) | |
;;{1 [1 4 7], 2 [2 5 8], 0 [3 6 9]} | |
(group-by #(mod % 3) (mapcat (partial repeat 3) (range 1 10))) |
This file contains 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
[(= (next (range 10)) | |
(rest (range 10))) | |
(= (next '(1)) ;; => nil | |
(rest '(1))) ;; => () | |
(= (next nil) ;; => nil | |
(rest nil))] ;; => () |
This file contains 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 test-app.core) | |
(defn get-rand-by-n | |
[n] | |
(* n (rand))) | |
(with-redefs | |
[clojure.core/rand (fn [] 2)] | |
(= 6 (get-rand-by-n 3))) |
This file contains 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 test-app.core) | |
(def r (range 10)) | |
(def s (set r)) | |
(def v (apply vector r)) | |
;; We can do this because set is seqable, so | |
;; drop-while can seq it. | |
(drop-while (partial > 5) s) |
This file contains 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 test-app.core) | |
;; get from a map, vector, set | |
(def r (range 10)) | |
(def m (->> r | |
(map (juxt (comp keyword str) identity)) | |
(into {}))) | |
(def v (apply vector (keys m))) | |
(def s (set (keys m))) |
This file contains 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 cli-tools-app.core | |
(:require [clojure.tools.cli :refer [cli]]) | |
(:gen-class)) | |
(defn parse-args | |
[args] | |
(cli args | |
["-u" "--username" "PropSol API username" :default | |
"rentpath@trinitypm"] | |
["-p" "--password" "PropSol API password" :default |
This file contains 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 a-map {:foo "foozle" :bar "barzle"}) | |
(prn "reader readable -- read-string works") | |
(prn a-map) | |
(eval (read-string (with-out-str (pr a-map)))) | |
(println "human readable -- read-string throws") | |
(println a-map) | |
(eval (read-string (with-out-str (print a-map)))) |
This file contains 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
(+ Long/MAX_VALUE 1) | |
;ArithmeticException integer overflow clojure.lang.Numbers.throwIntOverflow (Numbers.java:1388) | |
(+ (bigint Long/MAX_VALUE) 1) | |
;9223372036854775808N |