Skip to content

Instantly share code, notes, and snippets.

View paulcadman's full-sized avatar
💭
Studying Coq and HoTT

Paul Cadman paulcadman

💭
Studying Coq and HoTT
  • London
View GitHub Profile
@yossan
yossan / io_monad_sample.swift
Last active September 19, 2019 08:36
IO Monad with Swift
enum Pair<T, WORLD> {
case cons (T, WORLD) // (value, outside)
}
// Outside the computer
typealias WORLD = Any
// IO Monad Instance (a.k.a IO Action)
typealias IO<T> = (WORLD) -> Pair<T, WORLD>
@rlm
rlm / gist:746185
Created December 18, 2010 05:19
curry.clj
(ns sunil.curry)
(defn partial+
"Takes a function f and fewer than the normal arguments to f, and
returns a fn that takes a variable number of additional args. When
called, the returned function calls f with args + additional args.
differs from the core version in that it works on just one argument."
{:added "1.0"}
([f] f)
([f arg1]
@sunilnandihalli
sunilnandihalli / curry.clj
Created December 17, 2010 20:33
a macro to create fixed-arity curryable function in clojure
(defmacro def-curry-fn [name args & body]
{:pre [(not-any? #{'&} args)]}
(if (empty? args)
`(defn ~name ~args ~@body)
(let [rec-funcs (reduce (fn [l v]
`(letfn [(helper#
([] helper#)
([x#] (let [~v x#] ~l))
([x# & rest#] (let [~v x#]
(apply (helper# x#) rest#))))]