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 pyparser | |
(:require [clojure.spec.alpha :as s] | |
[clojure.string])) | |
;;given: | |
;;def foo(a, b, c=5, *args, d="dog", **kwargs): | |
;; ... | |
;;define a function that emits | |
;;'([a b & [args {c :c d :d :as kwargs :or {c 5 d "dog"}}]] |
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 mapextract | |
(:require [criterium.core :as criterium])) | |
(def m | |
(zipmap [:a :b :c :d :e :f :g :h :i :j :k :l :m :n :o :p] | |
(repeat :bingo))) | |
(def arr-map (select-keys m [:a :b :c :d])) | |
(def xs (vec (repeat 100 m ))) | |
(def arr-xs (vec (repeat 100 m ))) |
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
(def able | |
(reify Iterable | |
(iterator [this] (let [i (atom 0)] | |
(reify java.util.Iterator | |
(hasNext [this] true) | |
(next [this] | |
(print ".") | |
(swap! i inc))))))) | |
(defn lazyrator [^java.util.Iterator iter] |
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
`[~(range 10) ~[:this :vector :is] ~{:brought "to" :you "by"} ~@[:splicing :vectors] | |
~#{:sets} :and ~@'(:lists :together) :somewhat :trivially | |
~@{:even {:nested [:vectors]} :and [:maps :of :stuff] :are :easy} #{~@[:so :are :sets]} | |
~(eval `[:its :even [:easy ~@[:to :splice :quoted :forms] | |
~{:of :varying :levels #{:of-depth}}]])] | |
;;yields | |
[(0 1 2 3 4 5 6 7 8 9) | |
[:this :vector :is] | |
{:brought "to", :you "by"} |
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 workdist | |
(:require [clojure.core.async :as a :refer [chan >!! <!! <! >! go go-loop]])) | |
;;define some simple workloads | |
(def payloads | |
{:red (vec "red") | |
:green (vec "green") | |
:blue (vec "blue")}) | |
;;Generate 100 messages of :red :green :blue categories |
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 par | |
(:require [clojure.core.async :as a])) | |
(def my-data-log (atom [])) | |
(defn fetch-data! [n] | |
(Thread/sleep 1e3) | |
(swap! my-data-log conj (str "Fetched record: " n)) | |
n) |
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 numberdemo | |
(:require [clojure.pprint :as pprint])) | |
;;from Craig | |
;;doesn't handle decimals. | |
(defn commarize | |
"given the string representation of a number, insert a comma after | |
every three digits." | |
[num-str] | |
;;reverse the string since the first comma starts from the right |
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 perfect.reader.faster | |
(:require | |
[perfect.reader.generics :as generics] | |
[clojure.spec.alpha :as s] | |
[net.danielcompton.defn-spec-alpha :as ds]) | |
(:import | |
(org.dhatim.fastexcel.reader ReadableWorkbook | |
Sheet | |
Row | |
Cell |
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
;;Shim class for running app without | |
;;aot compilation issues. | |
;;entrypoint for some gui. | |
(ns blah.main | |
(:gen-class :main true)) | |
;;This is the main entry point for the app. | |
;;It's a good example of a shim-class, and | |
;;requires some arcane features to get things | |
;;working to avoid aot compilation of dependent |
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
;;A port of an awk script that munges | |
;;code to .org mode documentation, | |
;;let's do it with spec! | |
(ns spectraining.doc | |
(:require [clojure.spec.alpha :as s] | |
[clojure.spec.gen.alpha :as gen] | |
[clojure.spec.test.alpha :as stest] | |
[clojure.string :as str])) | |