Skip to content

Instantly share code, notes, and snippets.

@benfleis
benfleis / Batch.java
Created May 11, 2017 11:31
akka stream batch processing via manually materialized subgraph
package spss;
import java.util.Arrays;
import java.util.concurrent.CompletionStage;
import akka.*;
import akka.actor.ActorSystem;
import akka.stream.*;
import akka.stream.javadsl.*;
(defprotocol IAlias
(unalias [_]))
(deftype VersionAlias [version tag]
IAlias
(unalias [this] version))
(defn version-alias [version tag] (VersionAlias. version tag))
(defn version-alias? [x] (instance? VersionAlias x))
{:conjunction
[{:disjunction [e0 e1]}
{:disjunction [e1 e2]}
{:negation {:disjunction [e2 e3]}}]}
=>
{:disjunction
({:conjunction ({:negation (e2)} e2 e0 {:negation (e3)})}
{:conjunction ({:negation (e2)} e1 e2 {:negation (e3)})}
{:conjunction ({:negation (e2)} e1 {:negation (e3)})}
{:conjunction ({:negation (e2)} e1 e0 {:negation (e3)})})}
@benfleis
benfleis / itree.clj
Created March 25, 2015 21:38
quick hack interval tree, allowing glob matching, build upon sorted set
(ns itree
(:require [clojure.pprint :refer [pprint]]
[taoensso.timbre :refer [info spy]]))
;; allow for [:foo nil] to glob [:foo *]; data will never be inserted
;; w/ nil, but slice/subseq elements will.
(defn cmp [x y] (if (and x y) (compare x y) 0))
(defn cmp-s [[x0 x1] [y0 y1]]
(let [c0 (cmp x0 y0)