Skip to content

Instantly share code, notes, and snippets.

@reborg
reborg / rich-already-answered-that.md
Last active May 5, 2024 04:45
A curated collection of answers that Rich gave throughout the history of Clojure

Rich Already Answered That!

A list of commonly asked questions, design decisions, reasons why Clojure is the way it is as they were answered directly by Rich (even when from many years ago, those answers are pretty much valid today!). Feel free to point friends and colleagues here next time they ask (again). Answers are pasted verbatim (I've made small adjustments for readibility, but never changed a sentence) from mailing lists, articles, chats.

How to use:

  • The link in the table of content jumps at the copy of the answer on this page.
  • The link on the answer itself points back at the original post.

Table of Content

@mrb
mrb / abstint.md
Last active October 4, 2020 18:45
"Programs that eat programs" Works cited/bibliography
@Chouser
Chouser / externs_for_cljs.clj
Created June 17, 2013 13:44
Generate an externs.js file for arbitrary JS libraries for use in advanced Google Closure compilation, based on the ClojureScript code that uses the libraries.
(ns n01se.externs-for-cljs
(:require [clojure.java.io :as io]
[cljs.compiler :as comp]
[cljs.analyzer :as ana]))
(defn read-file [file]
(let [eof (Object.)]
(with-open [stream (clojure.lang.LineNumberingPushbackReader. (io/reader file))]
(vec (take-while #(not= % eof)
(repeatedly #(read stream false eof)))))))
(unifier/unify
{:as '{?x (?y ?z)}
:constraints {'?z (fnc [n] (number? n))}
'(?x ?a) '(["foo" 9] [1 2 3]))
;; previously you couldn't name '(?y ?z)
(unifier/unify
{:constraints {'?z (fnc [n] (number? n)}}
'((?y ?z) ?a) '(["foo" 9] [1 2 3]))
anonymous
anonymous / gist:4269466
Created December 12, 2012 16:53
when_logic.clj
(defc numberc [x]
(number? x))
(unifier '(?x) '(1) :when {'?x numberc})