Skip to content

Instantly share code, notes, and snippets.

View iitalics's full-sized avatar

Milo iitalics

  • Somerville, MA
View GitHub Profile
#include <stdio.h>
template <int N> struct fizz { enum { flags = 0 }; };
template<> struct fizz<0> { enum { flags = 1 }; };
template <int N> struct buzz { enum { flags = 0 }; };
template<> struct buzz<0> { enum { flags = 2 }; };
template <int F, int N> struct show { show() { printf("%d\n", N); } };
template <int N> struct show<1, N> { show() { printf("Fizz\n"); } };
#include <stdlib.h>
#include <stdio.h>
int n;
int fb;
void f() { fb |= 1; }
void b() { fb |= 2; }
void nop() {}
open import Level using (Level)
open import Function using (_$_; _∘_)
open import Data.List.Base
open import Data.List.Relation.Unary.Any using (Any; here; there)
open import Data.List.Relation.Unary.All using (All; []; _∷_)
open import Relation.Nullary using (¬_; yes; no)
open import Relation.Nullary.Negation using (contradiction)
open import Relation.Binary using (_⇒_; Decidable)
open import Relation.Binary.PropositionalEquality using (_≡_; _≢_)
let merge_fold_left' ~compare fx fy fxy xs ys ini =
let rec loop acc = function
| x :: xs, y :: ys ->
let c = compare x y in
if c < 0 then loop (fx x acc) (xs, y :: ys)
else if c > 0 then loop (fy y acc) (x :: xs, ys)
else loop (fxy x y acc) (xs, ys)
| x :: xs, [] -> loop (fx x acc) (xs, [])
| [], y :: ys -> loop (fy y acc) ([], ys)
| [], [] -> acc
@iitalics
iitalics / PKGCONFIG
Last active May 23, 2020 00:39
PKGCONFIG for tetr.io desktop client
pkgname=tetrio-desktop
pkgver=1.0.0
pkgrel=1
pkgdesc="TETR.IO desktop client. Modern yet familiar online stacker - play against friends and foes all over the world, or claim a spot on the leaderboards!"
arch=("any")
url="https://tetr.io/"
source=("https://tetr.io/about/desktop/builds/TETR.IO%20Setup.tar.gz")
license=()
md5sums=("b378f5a3cb8c37e327f8377898e0b3d0")
depends=("electron>=8.2.5")
@iitalics
iitalics / rose.ml
Last active October 29, 2023 07:28
Rose trees implemented in OCaml via binary trees
[@@@warning "-8"]
(** Abstract interface for monoids.
*)
module type Monoid_S = sig
type t
val zero : t
val ( + ) : t -> t -> t
(* Required laws:
module T0 = struct
module type S = sig type t end
end
(** Finite-map; open-to-extension; heterogenous values (type determined by the key).
*
* See the bottom of this file for an example use.
*
* New key types can be generated on the fly and used to modify or query the
* contents of the map. *)
// staged stream emitter (w/o unimportant details), to show how we ought to
// do region management.
// "NEW" comments indicate where the implementation differs from the current
// region-unaware version.
def emit(dstR: Code[Region], ir: IR, env: Env): EmTr =
...
@iitalics
iitalics / do.rkt
Last active December 19, 2019 19:25
#lang racket/base
(provide
do
with-bind-function)
(require
racket/stxparam
syntax/parse/define
(for-syntax racket/base))
object Sad {
case class TArray(required: Boolean = false)
case class A(t: TArray, n: Int)
class B {
def a: A = a.copy(t = TArray())
def t: TArray = a.t
}