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
;; Save this file as deps.edn in some directory that doesn't already | |
;; have such a file. | |
;; You must have the following installed for the command below to have | |
;; a chance of working: | |
;; + A JDK, e.g. from AdoptOpenJDK web site: https://adoptopenjdk.net | |
;; + Clojure CLI tools. Install instructions here: | |
;; https://clojure.org/guides/getting_started | |
;; + Node.js JavaScript runtime environment. Some prepackaged ways to |
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
;; Save this file as deps.edn in some directory that doesn't already | |
;; have such a file. | |
;; You must have the following installed for the command below to have | |
;; a chance of working: | |
;; + A JDK, e.g. from AdoptOpenJDK web site: https://adoptopenjdk.net | |
;; + Clojure CLI tools. Install instructions here: | |
;; https://clojure.org/guides/getting_started | |
;; + Node.js JavaScript runtime environment. Some prepackaged ways to |
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
;; Command to start ClojureScript REPL: | |
;; clj -Sdeps "{:deps {org.clojure/clojurescript {:mvn/version \"1.10.520\"}}}" -m cljs.main --repl-env node | |
(defn wrapme [wrapped-fn a another-fn] | |
(fn [& args] | |
(println "called wrapped fn") | |
(let [ret (apply wrapped-fn args)] | |
(apply another-fn a ret args) | |
ret))) |
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
(defproject anaphora "0.1.0-SNAPSHOT" | |
:url "https://medium.com/@sophiagoldnyc/anaphora" | |
:license {:name "Eclipse Public License" | |
:url "http://www.eclipse.org/legal/epl-v10.html"} | |
:dependencies [[org.clojure/clojure "1.10.0-master-SNAPSHOT"] | |
[org.clojure/data.avl "0.0.17"] | |
[org.clojure/data.int-map "0.2.4"] | |
[org.clojure/math.combinatorics "0.1.4"] | |
[org.clojure/tools.analyzer "0.6.9"] | |
[org.clojure/tools.analyzer.jvm "0.7.2"] |
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
;; Latest tools.analyzer.jvm as of Jul 29 2015 commit. | |
;; Clojure 1.8.0-alpha2 behavior (and I think for many previous | |
;; Clojure versions) | |
user=> (require '[clojure.tools.analyzer.jvm :as taj]) | |
nil | |
user=> (def x (taj/analyze '(defn foo [x] "Not a doc string" (* x x)))) | |
#'user/x |
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
(defproject useclj16 "0.1.0-SNAPSHOT" | |
:description "FIXME: write description" | |
:dependencies [[org.clojure/clojure "1.6.0"]] | |
:profiles {:dev {:dependencies [[criterium "0.4.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
;; Example: | |
;; (merge-sorted-seqs < (range 10 1000 3) (range 12 1000 5)) | |
(defn merge-sorted-seqs [cmpf seq1 seq2] | |
(let [seq1wins (and (seq seq1) | |
(or (nil? (seq seq2)) | |
(cmpf (first seq1) (first seq2))))] | |
(if seq1wins | |
(lazy-seq (cons (first seq1) | |
(merge-sorted-seqs cmpf (next seq1) seq2))) |
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
;; Clojure JIRA ticket CLJ-865: http://dev.clojure.org/jira/browse/CLJ-865 | |
;; was created with the intent of changing some of the behavior below, but it is | |
;; not clear as of late 2014 whether the behavior is considered a bug that should | |
;; be changed. | |
;; Nicola Mometto pointed out that there may be similar issues with metadata | |
;; being eliminated for primInvoke's and functions defined with definline. | |
;; Perhaps http://dev.clojure.org/jira/browse/CLJ-1533 is related. | |
user=> *clojure-version* |
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
user=> (def b 7) | |
#'user/b | |
user=> (def fplus2 (reify java.lang.Object (hashCode [user/b] (+ user/b 2)))) | |
#'user/fplus2 | |
user=> (.hashCode fplus2) | |
9 |
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
;; TBD: What is going on here? | |
;; Why does (Math/abs (f2 -3)) cause a | |
;; reflection warning, but neither of the other variants does? | |
user=> (clojure-version) | |
"1.6.0" | |
user=> (set! *warn-on-reflection* true) | |
true | |
user=> (defn ^{:tag 'long} f1 [x] (inc x)) |
NewerOlder