Skip to content

Instantly share code, notes, and snippets.

View namin's full-sized avatar

Nada Amin namin

View GitHub Profile
@bobatkey
bobatkey / gadts.sml
Created January 5, 2014 18:34
Encoding of GADTs in SML/NJ
(* This is a demonstration of the use of the SML module system to
encode (Generalized Algebraic Datatypes) GADTs via Church
encodings. The basic idea is to use the Church encoding of GADTs in
System Fomega and translate the System Fomega type into the module
system. As I demonstrate below, this allows things like the
singleton type of booleans, and the equality type, to be
represented.
This was inspired by Jon Sterling's blog post about encoding proofs
in the SML module system:
@jackrusher
jackrusher / heart-murmur.clj
Last active December 24, 2015 16:09
My first attempt at an aleatoric composition with Overtone. An example of the audio output is here: https://soundcloud.com/jackrusher/heart-murmur
(ns overtone-playground.heart-murmur
(:use overtone.core
overtone.inst.sampled-piano
overtone.samples.piano))
;; (boot-server)
;; (sampled-piano)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Reproducible randomness
@avescodes
avescodes / Editing Clojure with Emacs
Last active July 5, 2022 13:32
Get started editing Clojure in Emacs with this basic config.
Check out README.md to get started editing Clojure with Emacs.
@HairyFotr
HairyFotr / gist:4995607
Created February 20, 2013 13:38
Scala Clojure interop wrapper
class ClojureWrap(ns: String, objName: String) {
import clojure.lang.{RT,Var}
import scala.collection.mutable.HashMap
RT.loadResourceScript(objName+".clj")
val obj = ns+"."+objName
val funcs = new HashMap[String, Var]
def /(func: String, a: Any): Object =
funcs.getOrElseUpdate(func, RT.`var`(obj, func)).invoke(a.asInstanceOf[Object])
@TiarkRompf
TiarkRompf / GenericLifiting.scala
Last active November 30, 2017 16:28
generic class lifting and method forwarders
import language.experimental.macros
import language.dynamics
import scala.reflect.macros._
case class Rep[+T](x:String)
implicit def anyToRep[T](x:T) = new Rep[T](x.toString)
class ShouldLift[T]
@swannodette
swannodette / gist:3217582
Created July 31, 2012 14:52
sudoku_compact.clj
;; based on core.logic 0.8-alpha2 or core.logic master branch
(ns sudoku
(:refer-clojure :exclude [==])
(:use clojure.core.logic))
(defn get-square [rows x y]
(for [x (range x (+ x 3))
y (range y (+ y 3))]
(get-in rows [x y])))
@kmizu
kmizu / Amb.scala
Created March 13, 2012 12:48
Minimal implementation of amb by shift/reset
//scalac -P:continuations:enable
import scala.util.continuations._
object Amb{
def amb[T](elements: T*):T @suspendable = shift{k:(T=>Unit) => elements.foreach(k)}
def block(body : => Unit @suspendable): Unit = reset(body)
def main(args: Array[String]) {
block {
val a = amb(1, 2, 3)
val b = amb("A", "B", "C")
println(a, b)
@jonifreeman
jonifreeman / scalatoprolog.md
Created January 30, 2012 09:16
Scala type system -> Prolog