Skip to content

Instantly share code, notes, and snippets.

@swannodette
swannodette / notes.clj
Last active July 5, 2022 13:32
Generates lists of size M containing natural numbers which add up to N
;; list comprehensions are often used as a poor man's Prolog
;; consider the following, it has only one solution
;; [1 1 1 1 1 1 1 1 1 1] yet we actually consider 10^10 possibilities
(for [a (range 1 11)
b (range 1 11)
c (range 1 11)
d (range 1 11)
e (range 1 11)
f (range 1 11)
@kingtim
kingtim / eval_in_emacs.clj
Last active December 10, 2015 23:09
Prototype nrepl middleware for eval-in-emacs.
(ns org.kingtim.eval-in-emacs
(:require
[clojure.tools.nrepl.transport :as transport]
[clojure.tools.nrepl.middleware :refer [set-descriptor!]]
[clojure.tools.nrepl.middleware.session :refer [session]]
[clojure.tools.nrepl.misc :refer [response-for]])
(:import clojure.tools.nrepl.transport.Transport))
(def transports (atom {}))
@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])))