Skip to content

Instantly share code, notes, and snippets.

View iitalics's full-sized avatar

Milo iitalics

  • Somerville, MA
View GitHub Profile
(* This module, [S], defines a very minimal syntax tree that we are going to try to
convert into A-normal form (ANF). ANF is an intermediate form that makes control flow
explicit and lifts intermediate values into named variables. We are going to start with
a very basic lowering algorithm and gradually refine it until it is robust. *)
module S = struct
type name = string [@@deriving show]
type t =
| Var of name
| Int of int
use core::cell::Cell;
use core::mem::MaybeUninit;
use core::pin::Pin;
use core::ptr::NonNull;
use core::{fmt, marker, ptr};
/// Linked list node containing `T`. Uses a circular doubly-linked list. May be used
/// without heap allocations by initializing in-place, see [`Linked::init_in_place`].
///
/// Linked list nodes are automatically unlinked when dropped.
#lang racket
(define (macro-expand s)
(match s
[(list 'let vs b)
(define xs (map car vs))
(define es (map cadr vs))
(macro-expand `((lambda ,xs ,b) ,@es))]
[(list 'let* vs b)
(define xs (map car vs))
<html>
<head>
<title>Tiles</title>
<style>
html {
--alt1: oklch(0.68 0.17 276);
--alt2: oklch(0.68 0.17 40);
}
.tiles {
# expected rate to get n drops
def true_exp(n):
if n <= 0:
return 0
p2 = 1/100 # 2 drops
p1 = 18/100 # 1 drop
p0 = 81/100 # 0 drops
# expected rate to get n drops
def true_exp(n):
if n <= 0:
return 0
p_2 = 1/100 # 2 drops
p_1 = 18/100 # 1 drop
p_0 = 81/100 # 0 drops
# E_n = 1 + p_2 E_(n-2) + p_1 E_(n-1) + p_0 E_n
import random
def simulate():
kc = 0
N = 100000
for i in range(N):
n = 0
while n < 10:
# roll 1
if random.randint(1, 10) == 1:
/// Returns the next smallest integer with the same hamming weight as the input.
pub fn snoob(x: u32) -> u32 {
let mut ntz = x.trailing_zeros();
if x == 0 {
ntz = 0;
}
let least_one = x & x.wrapping_neg(); // nightly: x.isolate_least_significant_one()
let ripple = x + least_one;
let ones = (x ^ ripple).unbounded_shr(2 + ntz);
ripple | ones
class Clock {
constructor() {
this.time = 0;
this.bucket = new Array(32);
for (let i = 0; i < 32; i++) {
this.bucket[i] = [];
}
this.dirty = [];
}
xxx $ yarn run --help
Multiple commands match your selection:
0. yarn run
1. yarn run [--inspect] [--inspect-brk] [-T,--top-level] [-B,--binaries-only] <scriptName> ...
Run again with -h=<index> to see the longer details of any of those commands.
xxx $ yarn run --help -h=1
Unknown Syntax Error: Unsupported option name ("--help").