Skip to content

Instantly share code, notes, and snippets.

View miner's full-sized avatar

Steve Miner miner

View GitHub Profile
@miner
miner / gist:3240618
Created August 2, 2012 21:03 — forked from swannodette/gist:3217582
sudoku_compact.clj
(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])))
(defn init [vars hints]
@miner
miner / kein.sh
Last active January 4, 2021 09:35 — forked from cgrand/kein.sh
Launch a plain clojure repl according to project.clj without leiningen (most of the time)
#!/bin/bash
# launch a clojure plain repl but with options and classpath matching project.clj
# Except when project.clj changes (and on first launch), lein is not called.
if [ ! -f "project.clj" ]; then
echo "No project.clj"
exit 1
fi
# stat (mostly) protects against staleness of copied project dir
@miner
miner / ycombinator.clj
Last active January 4, 2021 09:38 — forked from z5h/ycombinator.clj
;;; 01/14/14 16:18 by miner -- Steve Miner revised this code to be more idiomatic Clojure.
;;;
; Short sidebar: Clojure has a special form for the efficient compilation of tail recursion.
; Something like this would work as a factorial function:
(defn fact2 [n]
(loop [n n acc 1]
(if (zero? n) acc (recur (dec n) (* n acc)))))
; We're not going to discuss `recur` any further as we're imagining a language that doesn't