{{ message }}

Instantly share code, notes, and snippets.

# Ambrose Bonnaire-Sergeantfrenchy64

• Bloomington, Indiana
Last active Dec 29, 2020
Boilerplate for running Clojure as a shebang script
View 00_script.clj
 #!/bin/sh #_( #_DEPS is same format as deps.edn. Multiline is okay. DEPS=' {:deps {clj-time {:mvn/version "0.14.2"}}} ' #_You can put other options here OPTS='
Created Nov 1, 2014
Fixed transducers from http://blog.podsnap.com/ducers2.html
View transducers.scala
 object TransducerUniversal { type Reduct[-A, R] = (R, A) => R trait Trans[+A, -B] { def apply[R](f: Reduct[A, R]): Reduct[B, R] } def map[A, B](f: A => B): Trans[B, A] = new Trans[B, A] { def apply[R](rf: Reduct[B, R]) = (r, a) => rf(r, f(a)) } def filter[A](p: A => Boolean): Trans[A, A] = new Trans[A, A] { def apply[R](rf: Reduct[A, R]) = (r, a) => if (p(a)) rf(r, a) else r } def comp[A,B,C](t1 : Trans[A, B], t2 : Trans[C, A]): Trans[C, B] = new Trans[C, B] { def apply[R](rf: Reduct[C, R]) = t1(t2(rf)) } def sequence[A, B](t: Trans[B, A], data: Seq[A]) = data.foldLeft(Seq[B]())(t(_ :+ _)) implicit class Compable[A,B](t1: Trans[A, B]) {
Last active Aug 29, 2015
Install Idris (latest) on Ubuntu 12.04
View idris-ubuntu-12.04.md

# Install GHC & Cabal-Install

``````apt-get update
apt-get install -y zlib1g-dev libncurses5-dev ghc cabal-install happy alex
``````

# Update Cabal-Install

``````cabal update
cabal install cabal-install
export PATH=\$HOME/.cabal/bin:./.cabal-sandbox/bin:\$PATH
``````
Created Oct 13, 2012
 (defmacro test-> "Takes an expression and a set of test/form pairs. Threads expr (via ->) through each form for which the corresponding test expression (not threaded) is true." [expr & clauses] (assert (even? (count clauses))) (let [g (gensym) pstep (fn [[test step]] `(if ~test (-> ~g ~step) ~g))] `(let [~g ~expr ~@(interleave (repeat g) (map pstep (partition 2 clauses)))]
Created Jul 8, 2012
View gist:3071099

# Anchors in Markdown

To create an anchor to a heading in github flavored markdown. Add - characters between each word in the heading and wrap the value in parens `(#some-markdown-heading)` so your link should look like so:

`[create an anchor](#anchors-in-markdown)`

Created May 17, 2012
unify_datums.clj
View gist:2719676
 (ns datomic-play.core (:use [datomic.api :only [db q] :as d]) (:require [clojure.core.logic :as l] [clojure.pprint :as pp])) (def uri "datomic:dev://localhost:4334/hello") (defprotocol IUnifyWithDatum (unify-with-datum [u v s]))
Created Apr 24, 2012 — forked from frenchy64/map_as_obj.clj
View map_as_obj.clj
 (defn analysis->map "Convert Java Object expr into nested maps" ; result type: ; (rec X (U {:op :def ; :env {:source Object ; :line Object} ; :var Var} ; {:op :if ; :env {:source Object ; :line Object}
Created Jan 31, 2012