Skip to content

Instantly share code, notes, and snippets.

View JustinSDK's full-sized avatar
👨‍👩‍👧
Working from home

Justin Lin JustinSDK

👨‍👩‍👧
Working from home
View GitHub Profile
@JustinSDK
JustinSDK / brainfuck.js
Last active April 8, 2018 06:53
Brankfuck - Hello,World
class List {
constructor(array) {
this.array = array;
}
get first() {
return this.array[0];
}
get tail() {
@JustinSDK
JustinSDK / lambda_calculus-4.js
Created March 19, 2018 07:37
console.log([1, 2, 3].map(elem => elem - 2))?(part 4)
console.log(array(
(y =>
(unit =>
(no_use =>
(yes =>
(no =>
(when =>
(not =>
@JustinSDK
JustinSDK / lambda_calculus_3.js
Last active March 20, 2018 09:03
console.log([1, 2, 3].map(elem => elem - 1))?(part 3)
let lt = (f => (x => f(n => x(x)(n)))(x => f(n => x(x)(n))))(m => l => f => (_ => _)((l => l(_ => _ => (_ => f => f(_ => _))))(l))(_ => (_ => (f => _ => f(_ => _))))(_ => (h => t => (l => r => f => f(l)(r))(h)(t))(f((p => p(l => _ => l))(l)))(m((p => p(_ => r => r))(l))(f))))((e => (l => (f => (x => f(n => x(x)(n)))(x => f(n => x(x)(n))))(v => r => l => (_ => _)((l => l(_ => _ => (_ => f => f(_ => _))))(l))(_ => r)(_ => v((h => t => (l => r => f => f(l)(r))(h)(t))((p => p(l => _ => l))(l))(r))((p => p(_ => r => r))(l))))(_ => (f => _ => f(_ => _)))(l))(e(_ => _ => (f => _ => f(_ => _)))))((f => (x => f(n => x(x)(n)))(x => f(n => x(x)(n))))(r => t => h => (_ => _)((n => n(_ => (_ => f => f(_ => _)))(_ => f => f(_ => _)))(h))(_ => t)(_ => r((h => t => (l => r => f => f(l)(r))(h)(t))(h)(t))))(_ => (f => _ => f(_ => _)))(f => x => f(x))(f => x => f(f(x)))(f => x => f(f(f(x))))))(e => (m => n => n(n => (p => p(l => _ => l))(n(p => (l => r => f => f(l)(r))((p => p(_ => r => r))(p))((n => f => x => f(n(f)(x)))((p =
@JustinSDK
JustinSDK / lambda_micro_lang_2.js
Last active April 20, 2018 01:13
用 ES6 箭號函式(lambda)實現的微語言之二
// 完全不使用 undefined
let y = f => (x => f(n => x(x)(n)))(x => f(n => x(x)(n)));
let yes = f => y => f;
let no = x => f => f;
let when = c => c;
let not = b => b(no)(yes);
let undef = _ => no;
@JustinSDK
JustinSDK / lambda_micro_lang_1.js
Last active March 17, 2018 03:34
用 ES6 箭號函式(lambda)實現的微語言之一
let yes = f => y => f();
let no = x => f => f();
let not = b => b(() => no)(() => yes);
let when = c => c;
let undef = (_ => _)();
// 系統邊界 ... 在這邊就是借助 JavaScript 執行環境,這讓事情簡單一些
@JustinSDK
JustinSDK / lambda-calculus-2.js
Last active March 19, 2018 06:01
console.log([1, 2, 3].map(elem => elem - 1))?(part 2)
function array(lt) {
let yes = f => y => f();
let no = x => f => f();
let when = c => c;
let undef = (_ => _)();
let is_undef = n => n === undef ? yes : no;
let pair = l => r => f => f(l)(r);
let left = p => p(l => _ => l);
@JustinSDK
JustinSDK / combinators.js
Last active March 27, 2018 00:12
Combinators
let y = f => (x => f(x(x)))(x => f(x(x)));
let z = f => (x => f(n => x(x)(n)))(x => f(n => x(x)(n)));
@JustinSDK
JustinSDK / lambda-calculus-1.js
Last active March 19, 2018 06:02
console.log([1, 2, 3].map(elem => elem - 2))?(part 1)
function array(lt) {
let pair = l => r => f => f(l)(r);
let left = p => p(l => r => l);
let right = p => p(l => r => r);
let nil = pair(undefined)(undefined);
let con = head => tail => pair(head)(tail);
let head = lt => left(lt)
let tail = lt => right(lt);
//radius determines the size of the hexagon
radius = 20;
levels = 15;
spacing = 2;
thickness = 20;
module hexagons(radius, spacing, levels) {
beginning_n = 2 * levels - 1;
offset_x = radius * cos(30);
@JustinSDK
JustinSDK / fractal_sequence.py
Last active April 14, 2020 07:57
碎形數列
'''碎形數列之一…每隔 n 個空格填入數字1、2、3、4、5 ....,例如 n 為 2 時…
1 _ _ 2 _ _ 3 _ _ 4 _ _ 5 _ _ 6 _ _ 7 _ _ 8 _ _ 9 _ _ ....
接著,在上面的數列中,每隔 2 個空格填入數字1、2、3、4、5 ....
1 1 _ 2 _ 2 3 _ _ 4 3 _ 5 _ 4 6 _ _ 7 5 _ 8 _ 6 9 _ _ ....
繼續在上面的數列中,每隔 2 個空格填入數字1、2、3、4、5 ....