Skip to content

Instantly share code, notes, and snippets.

View raindev's full-sized avatar

Andrew Barchuk raindev

View GitHub Profile
@raindev
raindev / game-of-life.hs
Created November 15, 2014 18:23
Game of life produced on the last coding session of Kyiv Global Day of Coderetreat 2014
import Data.List
-- Transform cells into next iteration
nextTurn :: (Integral a) => [(a,a)] -> [(a,a)]
nextTurn space = [(x, y) | (x,y,_) <- [head xs | xs <- cells space, length xs == 3 || (length xs == 4 && True `elem` ([x | (_,_,x) <- xs]))]]
-- Cells grouped by their coordinates
cells :: (Integral a) => [(a,a)] -> [[(a,a,Bool)]]
cells space = groupBy (\(x1,y1,_) (x2,y2,_) -> x1 == x2 && y1 == y2) (sort (neighbourhood space))
@raindev
raindev / State.java
Created June 2, 2014 07:59
Invalid Java enum declaration shown as good code in Intellij IDEA
package test;
import java.util.Collection;
import java.util.Collections;
import static java.util.Arrays.asList;
import static java.util.Collections.unmodifiableCollection;
public enum State {
STATE1 {