Skip to content

Instantly share code, notes, and snippets.

View lancejpollard's full-sized avatar
🐢
Code

Lance Pollard lancejpollard

🐢
Code
View GitHub Profile
@VictorTaelin
VictorTaelin / another_fp_prompt.md
Last active February 26, 2025 03:05
yet another FP prompt

The Interaction Calculus

The Interaction Calculus (IC) is term rewriting system inspired by the Lambda Calculus (λC), but with some major differences:

  1. Vars are affine: they can only occur up to one time.
  2. Vars are global: they can occur anywhere in the program.
  3. There is a new core primitive: the superposition.

An IC term is defined by the following grammar:

@VictorTaelin
VictorTaelin / towards_an_optimal_computer.md
Last active April 3, 2025 05:44
Higher-Order Company: Towards an Optimal Computer

Higher-Order Company: Towards an Optimal Computer

What is the true nature of computation?

A hundred years ago, humanity answered that very question, twice. In 1936, Alan invented the Turing Machine, which, highly inspired by the mechanical trend of the 20th century, distillated the common components of early computers into a single universal machine that, despite its simplicity, was capable of performing every computation conceivable. From simple numerical calculations to entire

@VictorTaelin
VictorTaelin / itt-coc.ts
Last active January 26, 2025 18:02
ITT-Flavored Calculus of Constructions Type Checker
// A nano dependent type-checker featuring inductive types via self encodings.
// All computation rules are justified by interaction combinator semantics,
// resulting in major simplifications and improvements over old Kind-Core.
// Specifically, computable annotations (ANNs) and their counterpart (ANN
// binders) and a new self encoding based on equality (rather than dependent
// motives) greatly reduce code size. A more complete file, including
// superpositions (for optimal unification) is available on the
// Interaction-Type-Theory repository.
// Credits also to Franchu and T6 for insights.
@VictorTaelin
VictorTaelin / implementing_fft.md
Last active April 21, 2025 16:27
Implementing complex numbers and FFT with just datatypes (no floats)

Implementing complex numbers and FFT with just datatypes (no floats)

In this article, I'll explain why implementing numbers with just algebraic datatypes is desirable. I'll then talk about common implementations of FFT (Fast Fourier Transform) and why they hide inherent inefficiencies. I'll then show how to implement integers and complex numbers with just algebraic datatypes, in a way that is extremely simple and elegant. I'll conclude by deriving a pure functional implementation of complex FFT with just datatypes, no floats.

@lancejpollard
lancejpollard / readme.md
Last active January 13, 2022 04:21
Universal Language Encoding (ULE)

Universal Language Encoding (ULE)

An alternative to the UTF encodings to handle more languages in a more compact way.

<language><characters><language><characters>...

Everything is in bytes.

@zmts
zmts / imageSize.md
Created June 6, 2020 16:48
Get image width and height with JavaScript

Get image width and height with JavaScript

function imageSize (image) {
  return new Promise((resolve, reject) => {
    try {
      const fileReader = new FileReader()

      fileReader.onload = () => {
 const img = new Image()
@IGJoshua
IGJoshua / lo me mi moi jbobau.org
Last active August 12, 2023 05:33
The lojban I speak

The lojban I speak

coi ro do mi’e la saski’o tu’a dei cu ve ciksi tu’a lo me mi moi jbobau

Introduction

let xn = (x, n) => x ** (n - 1n); // TODO: has a probably O(n!) complexity. More efficient algorithm needed.
function mod(x, n) {
const _xn = xn(x, n);
return (_xn - 1n) % n === 0n;
}
function withTimer(fn, timeName = 'Run time') {
return (...args) => {
console.time(timeName);
@rumkin
rumkin / chacha20.js
Last active May 29, 2020 10:50
Chacha20-Poly1305.js
/* chacha20 - 256 bits */
// Written in 2014 by Devi Mandiri. Public domain.
//
// Implementation derived from chacha-ref.c version 20080118
// See for details: http://cr.yp.to/chacha/chacha-20080128.pdf
function U8TO32_LE(x, i) {
return x[i] | (x[i+1]<<8) | (x[i+2]<<16) | (x[i+3]<<24);
}
@fnky
fnky / ANSI.md
Last active April 21, 2025 18:34
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27