Skip to content

Instantly share code, notes, and snippets.

View yuanchuan's full-sized avatar

Yuan Chuan yuanchuan

View GitHub Profile
@yuanchuan
yuanchuan / lambda.js
Last active October 28, 2017 06:28
fun
const assert = require('assert');
const cons = (a, list) => _cons => _cons(a, list);
const car = list => list(head => head);
const cdr = list => list((_, tail) => tail);
const nil = () => null;
const is_nil = list => car(list) === nil();
const length = list =>
is_nil(list) ? 0 : 1 + length(cdr(list));
@yuanchuan
yuanchuan / pattern-matching.js
Last active January 12, 2018 15:14
Erlang-like pattern matching in JavaScript
const MARK = {
symbol: {
name: '__mark__',
type: 'condition',
},
add(fn) {
let { name, type } = this.symbol;
let addon = { [name]: type };
return Object.assign((...args) => fn(...args), addon);
},
@yuanchuan
yuanchuan / index.html
Last active October 19, 2018 07:31
Alien land
<css-doodle>
:doodle {
@grid: 20x1 / 60vmin;
overflow: hidden;
}
:container {
transform: scale(25);
filter: @svg-filter(<svg>
<filter>
<feTurbulence baseFrequency="@r(.016, .056, .001)" seed="@r(100)" numOctaves="@r(8, 15)" />
@yuanchuan
yuanchuan / index.html
Created December 26, 2019 03:32
Matrix digital rain (animated version)
<main></main>