Skip to content

Instantly share code, notes, and snippets.

View frenchy64's full-sized avatar

Ambrose Bonnaire-Sergeant frenchy64

  • Madison, Wisconsin
View GitHub Profile
@frenchy64
frenchy64 / part1.clj
Created October 8, 2011 20:11
Evolving a logic programming language
;; Evolving a logic programming language
;; Based on sketches at https://github.com/frenchy64/Logic-Starter/blob/master/src/logic_introduction/decl_model.clj
;; A logic statement reduces to true or false.
true
;=> true
false
;=> false
@samth
samth / syntax.rkt
Created October 21, 2011 16:00
Programming with syntax in Typed Racket
#lang typed/racket
(: stx Syntax)
(define stx #'bar)
(syntax-case stx ()
[foo (identifier? #'foo) (symbol=? 'bar (syntax-e #'foo))]
[_ (error 'whoops)])
@swannodette
swannodette / gist:1408092
Created November 30, 2011 05:00
project.clj
(defproject clojurescript "0.1.0-SNAPSHOT"
:source-path "src/clj"
:dev-dependencies [[swank-clojure "1.4.0-SNAPSHOT"]])
@jlongster
jlongster / gist:1712455
Created January 31, 2012 19:37
traditional lisp macros
;; outlet code for implementing traditional macro expansion
;; macros
(define (expand form)
(cond
((variable? form) form)
((literal? form) form)
((macro? (car form))
(expand ((macro-function (car form)) form)))
(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}
@swannodette
swannodette / gist:2719676
Created May 17, 2012 15:35
unify_datums.clj
(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]))
@asabaylus
asabaylus / gist:3071099
Created July 8, 2012 14:12
Github Markdown Heading Anchors

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)

@richhickey
richhickey / thread.clj
Created October 13, 2012 17:43
new thread macros draft
(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)))]
@dysinger
dysinger / idris-ubuntu-12.04.md
Last active August 29, 2015 13:56
Install Idris (latest) on Ubuntu 12.04

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

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]) {