Skip to content

Instantly share code, notes, and snippets.

View ckirkendall's full-sized avatar

Creighton Kirkendall ckirkendall

  • Blue Manta Consulting
  • Cincinnati, Ohio
View GitHub Profile
@ckirkendall
ckirkendall / Lambda.clj
Last active December 11, 2015 09:48 — forked from bkyrlach/Lambda.scala
(ns lambda-calc.core)
;; THIS MACRO CREATES A LAMBDA THAT IS COMPATABLE WITH LAMBDA AS DEFINED IN
;; LAMBDA CALCULUS -> CURRIED NON-RECURSIVE
(defmacro f* [args & body]
(let [fsym (gensym "fn")
alist (for [n (range 1 (count args))]
(take n args))
curries (map #(do `(~(vec %) (partial ~fsym ~@%))) alist)]
`(fn ~fsym ~@curries (~args ~@body))))
(ns workbench.enlive.predicate
(:require
[clojure.zip :as z]
[workbench.enlive.engine
:refer [compile-step]]
[workbench.enlive.select
:refer [zip-select]]))
;; ## Builtin predicates
;;
;; The macros
;; most macros here alias names from select.cljs
;; they will get used in regular calls
(ns lib.select
(:require
[clojure.string :as str]))
;; selector syntax
(defn intersection [preds]
@ckirkendall
ckirkendall / tow-way.clj
Last active December 15, 2015 22:29
Two way relationship with immutable data structure.
(defprotocol XmlNode
(get-parent [_])
(get-children [_]))
(def empty-node
(reify XmlNode
(get-parent [_] nil)
(get-children [_] '())))
@ckirkendall
ckirkendall / wrap.clj
Last active December 16, 2015 01:49
wrap function in clojure based on Uncle Bob's http://blog.8thlight.com/uncle-bob/2013/01/07/FPBE3-Do-the-rules-change.html. I wrote this to provide a more readable and idiomatic version than what Uncle Bob presented.
(use '[clojure.string :only (split)])
(defn break-long-word [n word]
(if (> (count word) n)
[(take n word) (break-long-word n (drop n word))]
[word]))
(defn break-long-words [n words]
(mapcat #(break-long-word n %) words))
@ckirkendall
ckirkendall / Show.java
Last active December 16, 2015 17:38 — forked from bkyrlach/Show.java
abstract class Show<A> {
public static register(Class c, Show s){
Map<Class,Object> shows=TypeClassFactory.tcs.get(Show.class)
if(shows!=null){
shows.put(c,s);
}else{
shows = new Map<Class,Object>();
shows.put(c,s);
TypeClassFactory.tcs.put(Show.class, shows);
@ckirkendall
ckirkendall / speller.clj
Created July 8, 2013 20:38
Clojure version of Norvig's spell checker for LambdaJam.
(ns spell-checker.speller)
(defonce training-data (re-seq #"[a-z]+" (.toLowerCase (slurp "/home/ckirkendall/Development/clojure/spelling-jam/data/big.txt"))))
(defonce NWORDS (atom (frequencies training-data)))
(defn deletes [word]
package org.cinjug;
import java.util.Iterator;
interface Seq<T> {
public T next() throws EmptySequenceException;
public T peek() throws EmptySequenceException;
public boolean hasNext();
(ns chatter-box.event-bus-test
#+cljs
(:require-macros [cemerick.cljs.test :refer [deftest testing is]]
[cljs.core.async.macros :refer [go]])
(:require
[chatter-box.event-bus :as bus :refer [create-bus Component init accept-message? get-channel]]
#+clj [clojure.test :as test :refer [deftest testing is]]
#+cljs [cemerick.cljs.test :as t]
#+clj [clojure.core.async :as a :refer [alts! <! >! chan timeout go]]
#+cljs [cljs.core.async :as a :refer [alts! <! >! chan timeout]]))
(defn bind-view-watch-fn [id render-func]
(let [ky (str "EVB:" nid)]
(fn [ctx ref oval nval]
(let [node (.getElementById js/document id)]
(if node
(render-func node nval)
(remove-watch ref ky))))))