Skip to content

Instantly share code, notes, and snippets.

View wongjiahau's full-sized avatar

WJH wongjiahau

  • Malaysia
View GitHub Profile
@wongjiahau
wongjiahau / Ohm js grammar
Last active November 26, 2021 04:24
IBX (Infix Binary Expression)
// Note: the following grammar has not yet included Unary Tree
Ibx {
Exp
= BinaryExp
BinaryExp
= BinaryExp PriExp PriExp -- BinaryExp
| PriExp
PriExp
@wongjiahau
wongjiahau / solution.apl
Created October 10, 2021 01:57
Find the minimum missing integers
⌊/⍋⍤,⍨~⊢
@wongjiahau
wongjiahau / node_modules-graphql-execution-execute.js
Created May 25, 2021 08:20
GraphQL Profiling (look at spongebob comment)
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.execute = execute;
exports.executeSync = executeSync;
exports.assertValidExecutionArguments = assertValidExecutionArguments;
exports.buildExecutionContext = buildExecutionContext;
exports.collectFields = collectFields;
@wongjiahau
wongjiahau / Proof.ts
Created May 3, 2021 13:40
Proving Modus Ponens and Modus Tollens in Typescript
export const modus_ponens
// Proposition
// Given: A => B and A
// We can conclude: B
: <A, B>(f: (a: A) => B, a: A) => B
= <A, B>(f: (a: A) => B, a: A) => f(a)
// Note, in intuitionistic logic, ~A (a.k.a NOT A), is represented as A => never
export const modus_tollens
// Proposition:
@wongjiahau
wongjiahau / example.md
Last active March 18, 2021 10:02
Lambda + Let expression Unified Syntax

Lambdas using Let Notation

Introduction

As we all know, let expression is actually just a syntactic sugar for immediately invoked lambda expression (IILA). Actually not entirely correct, as pointed out in this comment.

For example, in Haskell:

let x = a in b

is the same as

@wongjiahau
wongjiahau / testing.ts
Last active July 21, 2020 01:38
Testing deno import url
export const x = import.meta.url
@wongjiahau
wongjiahau / import_all.ts
Created June 9, 2020 06:34
For testing compile speed in Deno
import * as _0 from 'https://deno.land/x/a0/mod.ts'
import * as _1 from 'https://deno.land/x/cmd/mod.ts'
import * as _2 from 'https://deno.land/x/adka_server/mod.ts'
import * as _3 from 'https://deno.land/x/actdb/mod.ts'
import * as _4 from 'https://deno.land/x/airtable/mod.ts'
import * as _5 from 'https://deno.land/x/adka/mod.ts'
import * as _6 from 'https://deno.land/x/abc/mod.ts'
import * as _7 from 'https://deno.land/x/amqp/mod.ts'
import * as _8 from 'https://deno.land/x/alosaur/mod.ts'
import * as _9 from 'https://deno.land/x/ascii_table/mod.ts'
@wongjiahau
wongjiahau / terser.min.js
Created June 3, 2020 14:21
Terser.js minified
//@ts-nocheck
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("source-map")):"function"==typeof define&&define.amd?define(["exports","source-map"],t):t((e=e||self).Terser={},e.sourceMap)}(this,(function(e,t){"use strict";function n(e){return e.split("")}function i(e,t){return t.includes(e)}t=t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t;class r extends Error{constructor(e,t){super(),this.name="DefaultsError",this.message=e,this.defs=t}}function o(e,t,n){!0===e&&(e={});const i=e||{};if(n)for(const e in i)if(D(i,e)&&!D(t,e))throw new r("`"+e+"` is not a supported option",t);for(const n in t)if(D(t,n))if(e&&D(e,n))if("ecma"===n){let t=0|e[n];t>5&&t<2015&&(t+=2009),i[n]=t}else i[n]=e&&D(e,n)?e[n]:t[n];else i[n]=t[n];return i}function a(){}function s(){return!1}function u(){return!0}function c(){return this}function l(){return null}var f=function(){function e(e,o,a){var s,u=[],c=[];function l(){var l=o(e[s],s),f=l instanceof r;return f&&(l=l.v),l instanceof
@wongjiahau
wongjiahau / funcords.js
Last active February 7, 2022 09:17
Funcords
/*
Funcords is a feature that combine functions and records.
If you think about it, record is actually a dependently typed function,
where the output type depends on the input type.
For example,
r = {'x': 1, 'y': 'yo'}
@wongjiahau
wongjiahau / untyped_record_calculus.c
Created January 10, 2020 02:00
Untyped record calculus
// Record type
{}: `{}
// construction
{x = {}}: `{x: `{}}
// destruction
{x: `{}} = {x = {}}
// abstraction