Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am loganmhb on github.
  • I am loganmhb (https://keybase.io/loganmhb) on keybase.
  • I have a public key ASDyENxMBbdQ6JRJQzfhxRtuHxaXXi-37Ikljq7O5dCyQwo

To claim this, I am signing this object:

@loganmhb
loganmhb / sset.lisp
Created October 2, 2019 13:49
Persistent sorted set implemented as a red-black tree in Common Lisp
;; todo: how do you actually manage dependencies?
(ql:quickload "generic-cl")
(ql:quickload "trivia")
;; Persistent red-black tree implemnetation per Okasaki's paper:
;; https://www.cs.tufts.edu/~nr/cs257/archive/chris-okasaki/redblack99.pdf
(defpackage sset
(:use generic-cl))
@loganmhb
loganmhb / cas.clj
Created February 21, 2017 18:36
fun pathological atom situation
(def a (atom 0))
(def f1 (future
(while (< @a 1000000000)
(swap! a inc))
(println "Done incrementing!")))
(def f2 (future
(swap! a (fn [current-val]
(println "Trying...`a' is" current-val)
@loganmhb
loganmhb / for.clj
Last active August 25, 2016 19:12
spec-based for macro
(ns spec-test.core
(:require [clojure.spec :as s])
(:refer-clojure :exclude [for]))
(s/def ::for-bindings
(s/* (s/cat :lval any?
:rval any?
:modifiers (s/* (s/cat :type #{:when :let :while}
:modifier-body any?)))))
@loganmhb
loganmhb / sentiment-scoring.clj
Last active August 29, 2015 14:17
Clojurepalooza homework - Sentiment scoring for words
(def test-responses [{:r 5, :c "This is awesome!"}
{:r 1, :c "This sucks!"}
{:r 3, :c "This is all right."}])
(defn clean-contents
[response]
(update-in response
[:c]
(comp (partial re-seq #"[a-z]+")