This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-----------= 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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]] |
OlderNewer