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 as-transducer [f] | |
"Convert function f into a transducer function. | |
This is merely a more convenient way to write an efficient reducing-step | |
function without the transducer signature. | |
The function should have the signature `(f transformer opaque-collection value)` | |
and return either `opaque-collection` or the return value of | |
`(transformer opaque-collection value)` to return new `opaque-collection` | |
things with `value` \"added\" to it. It can also box its return value with |
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 xyz | |
"Utilities for determining chunk position in XYZ files and processing | |
chunks using reducers. | |
Uses iota, which uses mmap()." | |
(:require [clojure.core.reducers :as r] | |
iota)) | |
(defn- step-chunk-starts | |
([] [(vector-of :int) 0 :find-start]) |
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- arguments-to-array | |
"This is the most jit-friendly way to turn arguments into an array. | |
js-this is a uint32 start index. | |
Call *exactly* like so: (.apply arguments-to-array start-index (js-arguments)) | |
Any other call pattern will prevent optimizations in calling function. | |
Returns a real js array of its arguments starting from start-index. | |
@param {...*} var_args" | |
[var_args] |
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 favila.async-util | |
"Some missing pieces of core.async. | |
as-transducer: Make a transducer function easily without Clojure 1.7. | |
go-pipe: async/pipe, but returns the go-loop. | |
fast-pipeline-blocking: faster than async/pipeline-blocking, but unordered results. | |
blocking-consumer: consume a channel with multiple worker threads." | |
(:require [clojure.core.async :as async | |
:refer [go go-loop <! >! <!! >!! close! take! put! chan]])) |
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 rollback | |
"Reassert retracted datoms and retract asserted datoms in a transaction, | |
effectively \"undoing\" the transaction. | |
WARNING: *very* naive function!" | |
[conn tx] | |
(let [tx-log (-> conn d/log (d/tx-range tx nil) first) | |
txid (-> tx-log :t d/t->tx) | |
newdata (->> (:data tx-log) | |
(remove #(= (:e %) txid)) |
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
SFCCA = Function.prototype.apply.bind(String.fromCharCode, null); | |
SFCC = String.fromCharCode | |
/** | |
* Dispatch table for multi-byte UTF8 code points. | |
* | |
* Index of (utf8_prefix_byte - 0x80) is length of UTF8 byte | |
* sequence + 1. 0 means invalid prefix byte. | |
* | |
* @type {!Int8Array} | |
* @const |
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 ^:const SIGN-BIT (bit-shift-left 1 63)) | |
(defn tempid-cljs->clj [tid] | |
(if (neg? tid) | |
(let [cljtid (-> tid (-) (bit-or SIGN-BIT))] | |
(d/tempid (d/part cljtid) (d/tx->t cljtid))) | |
tid)) | |
(defn tempid-clj->cljs [tid] | |
(if (neg? tid) |
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 nametext [hn] | |
(->> [:fhir-attr/HumanName.prefix :fhir-attr/HumanName.given | |
:fhir-attr/HumanName.family :fhir-attr/HumanName.suffix] | |
(mapcat #(get hn %)) | |
(filter not-empty) | |
(interpose \space) | |
(apply str))) | |
(defn humanname-text-tx [d] | |
(->> (d/datoms d :avet :phi.element/type "fhir-type/HumanName") |
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 zip-partition | |
"Return a sequence of length n of sequences of every nth item, each offset | |
by one. Suitable for building the rows of a table with n columns where the | |
sequence items flow down columns then rows. Example: | |
(zip-partition [0 1 2 3 4] 2) -> ((0 4) | |
(1 nil) | |
(2 nil) | |
(3 nil))" | |
[s 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 murmur3 | |
"Implementation of clojure.lang.Murmur3 in clojurescript (assuming javascript numerics). | |
by Francis Avila 2014-02-24") | |
(def imul | |
"32-bit signed integer multiply with overflow; alias of js/Math.imul. | |
Does not follow unchecked-multiply-int semantics! Only two args accepted; if | |
args are missing returns 0." | |
(if (exists? (aget js/Math "imul")) | |
(aget js/Math "imul") |