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
;; *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 |
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
(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}) |
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
;; 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]]] |