Skip to content

Instantly share code, notes, and snippets.

View ejackson's full-sized avatar

Edmund Jackson ejackson

  • UnityAI
  • Nashville, TN
View GitHub Profile
@ejackson
ejackson / core.clj
Created January 25, 2012 04:39
Unusual behaviour of symbol-macrolet
(ns timetable.core
(:refer-clojure :exclude [==])
(:use [clojure.core.logic]
[clojure.tools.macro]))
;; Basic form. Works
(run 10 [q]
(== [(lvar) (lvar) (lvar)] q)
(membero :history q)
(membero :math q)
@ejackson
ejackson / core.clj
Created February 2, 2012 23:31
Attempt at the problem
(ns timetable.core2
(:refer-clojure :exclude [==])
(:use [clojure.core.logic]
[clojure.tools.macro]))
;; --------------------------------------------------------
;; Useful goals
(defne rembero
"Succeeds if out is the list l with the first instance of element x removed"
[x l out]
@ejackson
ejackson / gist:1762346
Created February 7, 2012 21:57
Zoo Proposal
;;; zoo.clj -- Statistics library for Clojure built on the CERN Colt Library
;; by David Edgar Liebke http://incanter.org
;; March 11, 2009
;; Copyright (c) David Edgar Liebke, 2009. All rights reserved. The use
;; and distribution terms for this software are covered by the Eclipse
;; Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
;; which can be found in the file epl-v10.htincanter.at the root of this
;; distribution. By using this software in any fashion, you are
@ejackson
ejackson / gist:2723920
Created May 18, 2012 08:13 — forked from swannodette/gist:2719676
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]))
@ejackson
ejackson / *scratch*.el
Created June 8, 2012 11:39
Nothing to see here, yet.
;; MM""""""""`M
;; MM mmmmmmmM
;; M` MMMM 88d8b.d8b. .d8888b. .d8888b. .d8888b.
;; MM MMMMMMMM 88''88'`88 88' `88 88' `"" Y8ooooo.
;; MM MMMMMMMM 88 88 88 88. .88 88. ... 88
;; MM .M dP dP dP `88888P8 '88888P' '88888P'
;; MMMMMMMMMMMM
;;
;; M""MMMMMMMM M""M M""MMMMM""M MM""""""""`M
;; M MMMMMMMM M M M MMMMM M MM mmmmmmmM
@ejackson
ejackson / *gists*.txt
Created June 8, 2012 11:39
Nothing to see here, still.
2723920 2012-05-18 08:13:02 public unify_datums.clj
f262c68... 2012-04-19 12:45:56 private
1762346 2012-02-07 21:57:11 public Zoo Proposal
1726444 2012-02-02 23:31:59 public Attempt at the problem
+ 1674762 2012-01-25 04:39:48 public Unusual behaviour of symbol-macrolet
1431199 2011-12-04 20:33:49 public
1423801 2011-12-02 16:16:59 public A quick moving average
1380546 2011-11-20 17:37:54 public
1319377 2011-10-27 12:05:36 public
1293529 2011-10-17 19:29:20 public
(def v (into [] (repeatedly 1e5 #(rand 100))))
(defn rnd [x]
(Math/round x))
(defn prnd ^long [^double x]
(Math/round x))
(time (r/fold + (r/map rnd v)))
(time (r/fold + (r/map prnd v)))
@ejackson
ejackson / gist:5203517
Last active March 14, 2020 08:09
Non-fiction, Non-textbook stories on How the West was Won, and where it got us
-----------= Tales of Yore =-----------
* Hackers: Heroes of the Computer Revolution
(http://www.amazon.co.uk/Hackers-Heroes-Computer-Revolution-Anniversary/dp/1449388396)
* The soul of a new machine
(http://www.amazon.co.uk/Soul-New-Machine-Tracy-Kidder/dp/0140062491/ref=sr_1_2?s=books&ie=UTF8&qid=1363772696&sr=1-2)
* The brainmakers
(http://www.amazon.co.uk/Brainmakers-Scientists-Moving-Beyond-Computers/dp/067151055X/ref=sr_1_1?s=books&ie=UTF8&qid=1363772724&sr=1-1)
@ejackson
ejackson / nothing.html
Created April 20, 2011 21:15
nothing.html
<h1>Introduction</h1>
This is a brief post about how laziness can be used to construct a step-wise quicksort, or somebody gets excited about laziness.
<P>
Laziness is not something I'd come across before Clojure, and I've been repeatedly bitten by forgetting about it. So it was a real pleasure the other day to see the laziness revealed in some code, and for once not have this as the result of protracted debugging. I was so taken aback that I'm sharing the experience.
<h1>Quicksort</h1>
<h2>The Algo</h2>
We all know the <a href="http://en.wikipedia.org/wiki/Quicksort">algorithm</a>, and <a href="http://bilfp.wikidot.com/why-functional-programming-matters">here's</a> a pretty Clojure implementation:
<pre class="brush:Clojure">
(defn qsort [[pivot & tail]]