Skip to content

Instantly share code, notes, and snippets.

View andrewjpritchard's full-sized avatar

andrewjpritchard

View GitHub Profile
@andrewjpritchard
andrewjpritchard / main.rs
Created May 30, 2021 02:40
basic-non recursive heapsort in Rust
fn lchild(root: usize) -> usize {
root * 2 + 1
}
fn rchild(root: usize) -> usize {
root * 2 + 2
}
fn biggest_child<T: Ord>(slice: &mut [T], root: usize) -> Option<usize> {
let lchild = lchild(root);
@andrewjpritchard
andrewjpritchard / fizzBuzz.ts
Last active May 16, 2022 19:50
FizzBuzz implementation using nothing but closures
type Fix<A> = (arg: Fix<A>) => A
type Unit = <T>(
unit: () => T
) => T;
type Bool = <T>(
$true: () => T,
$false: () => T,
) => T;
@andrewjpritchard
andrewjpritchard / fizzBuzz.ts
Created June 3, 2021 09:38
FizzBuzz using nothing but closures and variable declarations
((
log: (str: string | number) => void,
join: (a: string, b: string) => string,
fizz: string,
buzz: string,
zeroNative: number,
succNative: (n: number) => number,
) => {
type Boolean = <T>(
$true: () => T,