Skip to content

Instantly share code, notes, and snippets.

View wilbowma's full-sized avatar

William J. Bowman wilbowma

View GitHub Profile
#lang racket
(require
(for-syntax
syntax/parse
racket/syntax))
;; unhygenic
(define-syntax (new-define-form syn)
(syntax-parse syn
@wilbowma
wilbowma / jfp.cls
Last active May 21, 2022 02:49
The JFP style and bib style modified to enable the DOI package to work, and to add URL and DOIs to the bib.
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{jfp}[2020/07/23 V1.6 Standard LaTeX document class]
%
\newif\ifcopoddhead\global\copoddheadfalse
\newif\ifOA\global\OAfalse
\newif\ifnolineno\global\nolinenofalse
\newif\ifnatbiboff\global\natbibofffalse
\newif\ifeqnum\global\eqnumfalse
\newif\ifkeyedin\global\keyedinfalse
\newif\iffirstproof\global\firstprooffalse
@wilbowma
wilbowma / macros-live.rkt
Created April 5, 2022 22:47
Macros lecture live code
#lang racket
;; ------------------------------------------------------------------------
;; Template helpers
;; ------------------------------------------------------------------------
(define-syntax (.... stx)
(syntax-case stx ()
[_
#`(error "Incomplete template at line" #,(syntax-line stx))]))
#lang racket
(require (for-syntax racket/syntax))
#|
1,000 fvars; let-syntax implementation
cpu time: 1162 real time: 1165 gc time: 156
10,000 fvars; let-syntax implementation
cpu time: 10928 real time: 10964 gc time: 1374
#lang racket
(require (rename-in racket/base [+ r:+]))
(provide +)
(define (join e1 e2)
(cond
[(and (number? e1) (number? e2))
number?]
[(and (number? e1) (symbol? e2))
#lang racket
(provide fact)
(define (fact n)
(apply * (build-list n add1)))
#lang sweet-exp racket
require (rename-in racket/base [+ r:+])
define +(e . rest)
cond
string? e
apply string-append e rest
number? e
apply r:+ e rest
#lang s-exp "redex-lang.rkt"
(axiom x : Nat)
(axiom y : Nat)
(lambda ((x : Nat)) y)
((lambda ((x : Nat)) y) 0)
; type error
#lang s-exp "interp.rkt"
(define f (lambda (x) #t))
(f #f)
#lang racket/base
(require racket/local)
(provide
;; the language, with some bits to demonstrate renaming in case you need to use Racket built-ins with the same name
true false
(rename-out [new-if if])
;; basic Racket stuff to get module with top-level expressions
#%module-begin
#%top