Skip to content

Instantly share code, notes, and snippets.

@leifp
leifp / fns.clj
Last active June 16, 2016 19:01
clojure.spec's for clojure.core
;; moved to https://github.com/leifp/spec-play
;; src/spec/clojure/fns.clj
@leifp
leifp / prom_alpha.py
Created October 17, 2015 11:28
Process mining alpha algo
import itertools as it
# alpha step 1
def activities(traces):
a = set()
for trace in traces:
a |= set(trace)
return a
# alpha step 2
@leifp
leifp / 0001-index-papers-by-canvas-region.patch
Last active August 29, 2015 14:21
Ideas on amithgeorge/reddit-dailyprogrammer-clojure 214_intermediate.clj
From 82dab3592fcc4f51fa2ce25133617502b1671429 Mon Sep 17 00:00:00 2001
From: Leif Poorman <leif.poorman@gmail.com>
Date: Sun, 17 May 2015 20:30:12 -0400
Subject: [PATCH 1/3] index papers by canvas region
---
src/rdp/214_intermediate.clj | 87 +++++++++++++++++++++++++++++++++-----------
1 file changed, 66 insertions(+), 21 deletions(-)
diff --git a/src/rdp/214_intermediate.clj b/src/rdp/214_intermediate.clj
@leifp
leifp / test-multiple-impls.clj
Created March 25, 2015 01:18
Best way to test multiple implementations of a protocol?
(ns test.multiple.implementations
(:require [clojure.test :refer [deftest is]]))
;;; Protocol and records that implement it
(defprotocol P (value [this]))
(defrecord One [] P (value [_] 1))
(defrecord Three [] P (value [_] 3))
;; potentially several more...
@leifp
leifp / diamond.clj
Created December 9, 2014 04:12
Solution to diamond kata
(ns diamond
(:require [clojure.string :as s]
[clojure.test :refer [deftest is]]))
(defn palindrome
[coll]
(concat coll (reverse (butlast coll))))
(defn char-range
[start-c end-c]
@leifp
leifp / gist:b4af5f4cd7289c38b55a
Last active August 29, 2015 14:01
core.logic solution to the Mensa Puzzle Calendar puzzle for April 8, 2014
(require '[clojure.core.logic :refer :all])
(require '[clojure.core.logic.fd :as fd])
(defn more-than-one-apart [x y]
(conde
[(fd/eq (> (- x y) 1))]
[(fd/eq (> (- y x) 1))]))
(defn billiards []
(let [dom (fd/interval 1 10)