| author | Nicole Wren |
|---|---|
| date | 2024-11-07 |
| paging | Slide %d / %d |
presented using slides
| function id<A>(x: A): A { | |
| return x; | |
| } | |
| function unreachable(x: never): never { | |
| return x; | |
| } | |
| function unused(_: unknown) {} |
| def o(P):P//.; | |
| def k(P):o(P|k(P)); | |
| def w(P;f):(.r=[]|P) as $r|.s=$r.s|.r+=[$r.r|f]; | |
| def s($r):(.s|match("^(?:"+$r+")")) as $m|.s|=.[$m.length:]|.m=$m.string; | |
| def _:s(" *"); | |
| def r($r;f):s($r)|.r+=[.m|f]; | |
| def l($s):select(.s|startswith($s))|.s|=.[$s|length:]|_; | |
| "[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?" as $d| | |
| "(?:[a-zA-Z0-9](?:[a-zA-Z0-9_.-]{0,61}[a-zA-Z0-9])?)" as $l| | |
| def K:r("(?:\($d)(?:\\.\($d))*/)?"+$l;.)|_; |
| author | Nicole Wren |
|---|---|
| date | 2024-11-07 |
| paging | Slide %d / %d |
presented using slides
I hereby claim:
To claim this, I am signing this object:
| #!/usr/bin/env nix-shell | |
| #!nix-shell -i python3 -p python3 | |
| import sys | |
| def compute(nums): | |
| def go(remaining_nums_stack, ops, size): | |
| if len(remaining_nums_stack) == 0 and size == 1: | |
| print(f'{eval_ops_stack(ops)} = {postfix_to_infix(ops)}') | |
| return |
| package main | |
| import ( | |
| "bytes" | |
| "fmt" | |
| "regexp" | |
| "strconv" | |
| "strings" | |
| "sync" | |
| "unicode/utf8" |
| package bitwise_test | |
| import ( | |
| "fmt" | |
| "testing" | |
| "testing/quick" | |
| ) | |
| // First, note some simple properties: | |
| // |
| import java.util.List; | |
| // some defunctionalization symbols to help us | |
| interface K1 {} // kind Type -> Type | |
| interface K2 {} // kind Type -> Type -> Type | |
| interface A1<F extends K1, A> {} // Apply1 :: (Type -> Type) -> Type -> Type | |
| interface A2<F extends K2, A, B> {} // Apply2 :: (Type -> Type -> Type) -> Type -> Type -> Type | |
| // we encode the existential using two tricks: | |
| // 1. the CPS transform: a ≅ ∀ r. (a -> r) -> r |
| package main | |
| import ( | |
| "bytes" | |
| "log" | |
| "net" | |
| "os" | |
| "github.com/google/gopacket" | |
| "github.com/google/gopacket/layers" |
| // Quick demonstration of expressing an LL(1) lexers/parsers as lazy iterators in Rust. | |
| // This lets you begin lexing/parsing without reallocating the input, loading the whole of the | |
| // input into memory at once, etc. This does not attempt to address some realistic concerns, such | |
| // as: | |
| // - Incremental parsing; you can't resume a partial parse, which would be annoying if doing | |
| // streaming parsing. For example, if you're writing a Lisp REPL, you might want to allow the | |
| // user to type part of a function call, hit "enter" before they've closed the parentheses, and | |
| // keep typing arguments on separate lines, deferring the execution until they've closed the | |
| // expression. This usually requires something like incremental parsing, which this can't do. | |
| // - Error messages; no location information is retained for good error message reporting! |