Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/109/three.min.js"></script>
<style>
html, body {
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/109/three.min.js"></script>
<script src="./scripts/OrbitControls.js"></script>
<style>
@ajeffrey
ajeffrey / cgol.js
Last active September 30, 2017 16:02
Functional CGoL
const irange = (a, b) => R.range(a, b + 1);
const neighbourRange = x => irange(x - 1, x + 1);
const between = R.curry((a, b, x) => x >= a && x < b);
const cellExists = (x, y) => between(0, grid.length, y) && between(0, grid[0].length, x);
const getCell = R.curry((x, y, grid) => cellExists(x, y) ? grid[y][x] : 0);
const neighbourhood = (x, y) => R.xprod(neighbourRange(x), neighbourRange(y));
const adjacent = R.curry((x, y) => R.reject(R.equals([x, y]), neighbourhood(x, y)));
const getCells = R.curry((cells, grid) => R.map(([x, y]) => getCell(x, y, grid), cells));
alias gc="git checkout"
alias gd="git diff"
alias gb="git branch"
alias gs="git status"