Skip to content

Instantly share code, notes, and snippets.

View ahitrin's full-sized avatar
💭
Arctic code contributor? Much cool... wow!

Andrey Hitrin ahitrin

💭
Arctic code contributor? Much cool... wow!
View GitHub Profile
@ahitrin
ahitrin / hexlife_core.clj
Last active December 31, 2015 04:39
Some experiments with Conway's game of life on the hexagonal field
(ns hexlife.core
(:use clojure.set))
(defn nbrs [[x y]]
"Расчет координат соседей для данной клетки с координатами [x y]"
(let [++ (fn [x] (+ x 1)) -- (fn [x] (- x 1))]
#{[(-- x) (-- y)] [(-- (-- x)) y] [(-- x) (++ y)]
[(++ x) (-- y)] [(++ (++ x)) y] [(++ x) (++ y)]}))
; (= (nbrs [3 2]) #{[2 1] [4 3] [2 3] [1 2] [4 1] [5 2]})
@ahitrin
ahitrin / likes.clj
Created November 9, 2012 19:08
Перевод примера из книги "Seven Languages in Seven Weeks" с Prolog на clojure.core.logic
(ns logic-in-clojure.core
(:refer-clojure :exclude [==])
(:use clojure.core.logic))
;; prolog example:
;;
;; likes(wallace, cheese).
;; likes(grommit, cheese).
;; likes(wendolene, sheep).
;; friend(X, Y) :- \+(X = Y), likes(X, Z), likes(Y, Z).
@ahitrin
ahitrin / TTest.java
Created August 9, 2012 07:19
JUnit Theories usage
import static org.junit.Assume.assumeTrue;
import org.junit.experimental.theories.DataPoint;
import org.junit.experimental.theories.DataPoints;
import org.junit.experimental.theories.Theories;
import org.junit.experimental.theories.Theory;
import org.junit.runner.RunWith;
/**
@ahitrin
ahitrin / gist:1992287
Created March 7, 2012 09:49
Need to automate some git magic ;)
git checkout 4470c77223d48d8145fdd1be42743d88e341479f && git format-patch HEAD^ &&
git checkout ef0924b4ae6a5d9775d478b1e98a8d26eef445bb && git format-patch HEAD^ --start-number 2 &&
git checkout a870c8f9cd2b42b433ef6294a752475e0adba122 && git format-patch HEAD^ --start-number 3 &&
git checkout 50deb9db151419882c1bdba10311024c05471875 && git format-patch HEAD^ --start-number 4 &&
git checkout 3f46f94f94ac6fc676a2491848ec21f7e762cb50 && git format-patch HEAD^ --start-number 5 &&
git checkout master