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
- [2] => Paper Object | |
- ( | |
- [id:Paper:private] => | |
- [title:Paper:private] => TestPaper | |
- [author:Paper:private] => | |
- [authorID:Paper:private] => 0 | |
- [lastEditor:Paper:private] => | |
- [dateSubmitted:Paper:private] => | |
- [lastEdited:Paper:private] => | |
- [paperSynopsis:Paper:private] => |
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 my-count [coll] | |
(reduce (fn [n x] (inc n)) 0 coll)) | |
(my-count [1 2 3 3]) | |
(defn my-reverse [coll] ;;only works for vectors atm | |
(reduce (fn [xs x] (into [x] xs)) [] coll)) | |
(my-reverse [1 2 3]) |
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 count-dots [s] | |
(count (filter #(= \. %) s))) |
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 reverse-int | |
"Returns an integer with its digits reversed, e.g. 123 returns 321" | |
[x] | |
(BigInteger. (su/reverse (pr-str x)))) | |
(defn palindromic? | |
"Returns true if the number is palindromic, e.g. 121, 1234321" | |
[x] | |
(= x (reverse-int x))) |
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
(->> (clojure.lang.Compiler/analyze clojure.lang.Compiler$C/EVAL | |
'(let [a 3 b 4] a)) .fexpr .methods first .locals keys (map #(.sym | |
%))) |
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
(defmodel User | |
:username | |
:password) | |
(defmodel Comment | |
:text | |
[:belongs-to User]) | |
(defmodel Post | |
:text |
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 clojure_refactoring.rename-fn-test | |
(:use clojure.test)) | |
(deftest test-fn-location | |
(in-ns 'refactoring-test-fn-rename) | |
(clojure.core/refer-clojure) | |
(defn a [b] (inc b)) | |
(in-ns 'clojure_refactoring.rename-fn-test) | |
(refer 'refactoring-test-fn-rename) | |
(is (not= (find-var 'refactoring-test-fn-rename/a) |
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
(deftest test-fn-location | |
(create-ns 'refactoring-test-fn-rename) | |
(with-ns 'refactoring-test-fn-rename | |
(clojure.core/refer-clojure) | |
(defn ^{:line 19 :file "foo.clj"} a [b] (inc b))) | |
(is (= (:line (meta (find-var 'refactoring-test-fn-rename/a))) | |
19)) | |
(remove-ns 'refactoring-test-fn-rename)) |
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
(deftest test-fn-location | |
(create-ns 'refactoring-test-fn-rename) | |
(with-ns 'refactoring-test-fn-rename | |
(clojure.core/refer-clojure) | |
(defn a [b] (inc b))) | |
(is (= (:line (meta (find-var 'refactoring-test-fn-rename/a))) | |
19)) | |
(remove-ns 'refactoring-test-fn-rename)) |
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
BartJ: | |
I have read chapter 1 (which is freely available) and I can tell you that, I think this is *THE* book to learn Clojure if you are a programmer. | |
What I love about the book? | |
1. Clarity of explanation | |
2. Conversant style | |
3. Very coherent, succinct and to the point examples. |