Skip to content

Instantly share code, notes, and snippets.

View bennn's full-sized avatar

Ben Greenman bennn

View GitHub Profile
;; List of high-frequency English words.
;; Taken from John Clement's morse-code library
;; https://github.com/jbclements/morse-code-trainer/blob/master/morse-code-trainer/frequency.rktd
(
"the"
"be"
"and"
"of"
"to"
"a"
#lang racket/base
;; Testing 3 implementations of string-contains?
;; 1. Using a simple regular expression
;; 2. Using a for loop
;; 3. Using a let loop
;; To run the freq-test, you'll want to download the file "common-words.rktd"
;; from this gist: https://gist.github.com/bennn/7efd60b4809a475af297
#lang racket/base
(module trie typed/racket
(provide lookup bind trie insert Trie tries)
(require racket/match)
(define-type-alias (Key A) (Listof A))
(define-struct: Mt ())
(define-struct: (A) Some ([elem : A]))
#lang racket/base
;; Minimized version of `good-news.rkt`
;; Runs on (slowly) on 6.3, crashes on 6.3.0.11
;;
;; Error message:
;; vector-ref: chaperone produced a result that is not a chaperone of the original result
;; chaperone result: (object:automata% ...)
;; original result: (object:automata% ...)
;; context...:
#lang racket/base
;; Apparently builds repeated wrappers
;; when comparing a recursive contract to an "opaque" recursive contract
;;
;; (object/c (-> evaluate ... (object/c (-> evaluation ...
;; vs
;; (recursive-contract g27 #:impersonator)
;;
;; Not sure where the recursive contract came from
#lang racket/base
(module automata racket/base
(provide
choose-randomly
build-automata)
(require racket/class racket/match)
(define (choose-randomly vals num-to-choose)
#lang racket/base
;; Repeatedly passes an object through a simple type boundary.
(define OPAQUE-TIME 1)
(define ITERS 30000)
(module t typed/racket/base
(require typed/racket/class)
(define-type C% (Class (f (-> C C))))
#lang racket
(require
(prefix-in - (only-in racket/base struct))
(for-syntax syntax/parse racket/syntax))
(define-syntax (struct stx)
(syntax-parse stx
[(_ name (field* ...) other-arg* ...)
#:with define-name (format-id stx "define-~a" (syntax-e #'name))
#:with (name-field ...) (for/list ([field (in-list (syntax-e #'(field* ...)))])
#lang rosette
;; Posted to Coq-Club by Fred Smith, 2016-09-24
;; https://sympa.inria.fr/sympa/arc/coq-club/2016-09/msg00185.html
;; The five-story Manning Building, located in the Wall Streat area of
;; Manhattan, houses the home offices of Matt and four other prominent
;; businessmen.
;;
;; Each man's business is located on a different floor of the building, and each
#lang racket
(require file/glob pict racket/draw)
(define (path->pict path)
(bitmap (make-object bitmap% path 'png)))
(define p
(parameterize (#;[current-directory (build-path "Users" "ben" "Desktop")])
(apply vc-append 20 (map path->pict (glob "/Users/ben/Desktop/Screen*png")))))