Skip to content

Instantly share code, notes, and snippets.

View mikera's full-sized avatar

Mike Anderson mikera

View GitHub Profile
@mikera
mikera / clj-1.8.0-alpha2-tuple-perf.clj
Last active August 29, 2015 14:25 — forked from ptaoussanis/clj-1.8.0-alpha2-tuple-perf.clj
Benchmarking for tuple performance
;; *clojure-version*
;; (require '[taoensso.encore :as encore])
(let [v [1 2 3 4]
x 1
y 2
z 3]
(encore/qbench ; Returns fastest of 3 sets of lap times for each form, in msecs
1000000 ; Number of laps
@mikera
mikera / clojure-match.clj
Created September 5, 2012 04:51 — forked from ckirkendall/clojure-match.clj
Language Compare F#, Ocaml, Scala, Clojure, Ruby and Haskell - Simple AST example
(use '[clojure.core.match :only [match]])
(defn evaluate [env [sym x y]]
(match [sym]
['Number] x
['Add] (+ (evaluate env x) (evaluate env y))
['Multiply] (* (evaluate env x) (evaluate env y))
['Variable] (env x)))
(def environment {"a" 3, "b" 4, "c" 5})
;; enodyt's solution to Game of Life
;; https://4clojure.com/problem/94
(fn [board]
(let [dx (count (first board))
dy (count board)
neighbours (fn [pos board]
(let [xs [[-1 -1] [0 -1] [1 -1]
[-1 0] [1 0]
[-1 1] [0 1] [1 1]]]