Skip to content

Instantly share code, notes, and snippets.

View deeglaze's full-sized avatar

Dionna Amalie Glaze deeglaze

View GitHub Profile
@deeglaze
deeglaze / gist:3499555
Created August 28, 2012 16:07
Switch hyphen and underscore for Coq editing in emacs
(defun switch-hyphen ()
(interactive)
(define-key coq-mode-map (kbd "-") '(lambda () (interactive) (insert "_")))
(define-key coq-mode-map (kbd "_") '(lambda () (interactive) (insert "-"))))
(add-hook 'coq-mode-hook 'switch-hyphen)
@deeglaze
deeglaze / gist:3707924
Created September 12, 2012 16:33
Problematic define
#lang racket
(define (f x) (cond [#f ;; or some other arbitrary computation that gives #f
(g x)]
[else x]))
(f 0)
(define (g x) x)
@deeglaze
deeglaze / compile-0cfa.rkt
Created October 4, 2012 17:24 — forked from dvanhorn/compile-0cfa.rkt
Compilation for 0CFA with lazy dereferencing
#lang racket
(require racket/trace
(for-syntax syntax/parse))
;; 0CFA in the AAM style on some hairy Church numeral churning
;; Soundness, but at what cost?
(define <- (case-lambda))
(begin-for-syntax
@deeglaze
deeglaze / compare.rkt
Created October 4, 2012 22:51
Performance discrepancies with macro generalization
#lang racket/load
(module tweaks racket
(require (for-syntax syntax/parse))
(provide <- for/union for*/union for*/set
appl fix do join extend get-cont lookup-env lookup P parse
compile widen push
join-stores s->c c->s
(struct-out ev^)
(struct-out co^)
@deeglaze
deeglaze / betterdsr.rkt
Created October 15, 2012 16:32
A better define-syntax-rule
(require (for-syntax syntax/parse))
; syntax classes, syntax-parse patterns and unquote-syntax in your define-syntax-rule!
(define-syntax (define-syntax-rule* stx)
(syntax-parse stx
[(_ (name patterns ...) body ...)
(syntax/loc stx
(define-syntax (name syn)
(syntax-parse syn
[(_ patterns ...)
(quasisyntax/loc syn (begin body ...))])))]))
@deeglaze
deeglaze / raco-doc.el
Created October 24, 2012 15:54
Hotkeys for quick racket documentation lookup. Requires paredit.
(setq raco-location "raco")
(require 'paredit)
(setq raco-doc-history nil)
(defun call-raco-doc (text)
(shell-command (concat raco-location " doc -- '" text "' &")))
(defun get-current-word ()
(paredit-handle-sexp-errors
(save-excursion
@deeglaze
deeglaze / count-bits.rkt
Created November 27, 2012 14:55
Count 1s in fixnums
#lang racket
(require racket/unsafe/ops
(for-syntax racket/fixnum racket/vector))
(provide fxcount)
;; Count set bits for 30 bit number in 5 steps.
;; for 62 bit number in 6.
(define-for-syntax lut
#(#x2AAAAAAA
#x0CCCCCCC
@deeglaze
deeglaze / toyPDCFA.rkt
Created May 2, 2013 17:59
Simple but buggy PDCFA
#lang racket
(require redex)
(define-language L
[e x (e e) lam (let ([x e]) e)]
[lam (λf (x) e)]
[λf λ lambda]
[x variable-not-otherwise-mentioned]
;; Machine
[ρ (side-condition (name ρ any) (hash? (term ρ)))]
@deeglaze
deeglaze / toy-wide.rkt
Last active December 16, 2015 22:08
Widened version of buggy PDCFA
#lang racket
(require redex)
(define-language L
[e x (e e) lam (let ([x e]) e)]
[lam (λf (x) e)]
[λf λ lambda]
[x variable-not-otherwise-mentioned]
;; Machine
[ρ (side-condition (name ρ any) (hash? (term ρ)))]
@deeglaze
deeglaze / exercise7.rkt
Created May 16, 2013 19:41
Do the scientific 7 minute workout... with Racket!
#lang racket
(provide main)
(require (planet clements/rsound) 2htdp/universe 2htdp/image)
;; Helpful app to implement the exercise plan in
;; http://well.blogs.nytimes.com/2013/05/09/the-scientific-7-minute-workout/
(define exercises '("Jumping jacks"
"Wall sit"
"Push ups"