Skip to content

Instantly share code, notes, and snippets.

View bens's full-sized avatar

Ben Sinclair bens

  • Sydney, Australia
  • 08:09 (UTC +10:00)
View GitHub Profile
@bens
bens / hellosdlgl31.zig
Created May 10, 2020 14:36
Hello World for OpenGL 3.3 with SDL2 in ziglang
const std = @import("std");
const Allocator = std.mem.Allocator;
const c = @cImport({
@cInclude("./gl_core_3_3.h");
@cInclude("SDL2/SDL.h");
@cInclude("SDL2/SDL_opengl.h");
});
const SDLError = error{
FailedInit,
@bens
bens / fold.ts
Last active September 7, 2020 01:14
Compositional folds in typescript
export default class Fold<A, B> {
private constructor(
private readonly state: any,
private readonly step: (x: A, st: any) => any,
private readonly done: (st: any) => B
) {}
public static of<A, B, S>(
state: S,
step: (x: A, st: S) => S,