Skip to content

Instantly share code, notes, and snippets.

View keybase.md

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 Oct 2, 2019
Persistent sorted set implemented as a red-black tree in Common Lisp
View sset.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 Feb 21, 2017
fun pathological atom situation
View cas.clj
(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 Aug 25, 2016
spec-based for macro
View for.clj
(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 Aug 29, 2015
Clojurepalooza homework - Sentiment scoring for words
View sentiment-scoring.clj
(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]+")