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
;; 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
(ns inputstream.core | |
(:require [clojure.java.io :as io])) | |
(defn read-is [^java.io.InputStream is] | |
(let [bufsize 8192 | |
buf (byte-array bufsize)] | |
(loop [total-len 0] | |
(let [n (.read is buf)] | |
(cond |
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
;; In a fresh Clojure 1.5.1 'lein repl' | |
;; clojure.edn is not loaded yet | |
user=> (clojure.edn/read-string "(5)") | |
ClassNotFoundException clojure.edn java.net.URLClassLoader$1.run (URLClassLoader.java:366) | |
;; trying to eval this form does not do it, because it fails to analyze as a whole | |
user=> (eval `(when true (require 'clojure.edn) (clojure.edn/read-string "(5)"))) |
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 piper.core | |
(:require [clojure.java.io :as io] | |
[clojure.string :as str]) | |
(:import (java.io Reader Writer BufferedReader))) | |
(defn str-seq-reader | |
"Return a java.io.Reader that returns the same sequence of | |
characters as are in the concatenation of the sequence of strings | |
given as an argument. Consumes only as much of the sequence as needed | |
for any given read operation." |
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
package perf; | |
import clojure.lang.AFunction; | |
import clojure.lang.IFn; | |
import clojure.lang.Indexed; | |
import clojure.lang.Numbers; | |
import clojure.lang.RT; | |
import clojure.lang.Var; | |
import java.awt.image.BufferedImage; | |
import perf.core.foo.fn__14; |
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 use of unresolve: | |
;; user=> (unresolve #'replace) | |
;; (replace clojure.core/replace) | |
;; user=> (use 'clojure.string) | |
;; WARNING: replace already refers to: #'clojure.core/replace in namespace: user, being replaced by: #'clojure.string/replace | |
;; WARNING: reverse already refers to: #'clojure.core/reverse in namespace: user, being replaced by: #'clojure.string/reverse | |
;; nil | |
;; user=> (unresolve #'replace) | |
;; (replace clojure.string/replace) |
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 |
NewerOlder