Skip to content

Instantly share code, notes, and snippets.

Begin Dump
Begin Racket3m
<application-code>: 13037 965792
<unary-application-c: 19475 623200
<binary-application-: 10566 422640
<sequence-code>: 3250 123256
<branch-code>: 7746 309840
<procedure-code>: 15131 1089432
<let-value-code>: 708 28320
<let-void-code>: 557 13368
@dyoo
dyoo / dump1.txt
Last active December 16, 2015 11:29
Begin Dump
Begin Racket3m
<application-code>: 13037 965792
<unary-application-c: 19475 623200
<binary-application-: 10566 422640
<sequence-code>: 3250 123256
<branch-code>: 7746 309840
<procedure-code>: 15131 1089432
<let-value-code>: 708 28320
<let-void-code>: 557 13368
@dyoo
dyoo / revised-scribble-block.rkt
Created April 20, 2013 00:36
A version of scribble-block to do escapes but still permit definition.
#lang scribble/base
@;; Submodule to provide support for a "block"-like form for Scribble documents.
@;;
@;; Adapted from racket/block
@;;
@;; The subexpressions are all collected into a list.
@;; Perhaps something like this belongs in the scribble library?
@(module scribble-block racket/base
@dyoo
dyoo / escaping-example.scrbl
Last active December 16, 2015 10:58
An example of escapes for @
#lang scribble/base
@title{Larger example}
@(define (double x)
(list x x))
@; Everything within the following will be escaped. use |^ to unescape.
@list|^{
@dyoo
dyoo / interp.py
Last active December 16, 2015 09:49
Example of revised code to interpret commands.
class p(object):
def __init__(self, *elts):
"""Construct a representation of a path.
(We'll cheat a little by using a list of strings.)"""
self.path = elts
def interp(self, data):
for p in self.path:
data = data[p]
return data
@dyoo
dyoo / gauss-with-prompts.rkt
Created April 18, 2013 18:28
Gauss sum, using a very perverse loop. Really a test of continuation prompts.
#lang racket
(define (f i acc)
(cond [(> i 0)
(abort-current-continuation (default-continuation-prompt-tag)
(lambda ()
(f (sub1 i) (+ i acc))))
(printf "You should not see this\n")
(/ 1 0)]
[else
@dyoo
dyoo / pretty-print-json.rkt
Last active December 16, 2015 07:28
Pretty printing json
#lang racket/base
(require json
data/order)
(define datum< (order-<? datum-order))
(define (pretty-write-json x
#:output-port [o (current-output-port)]
#:null [jsnull (json-null)]
#:encode [enc 'control]
@dyoo
dyoo / gist:5380369
Last active December 16, 2015 04:49
#lang racket
(define-syntax (verify stx)
(syntax-case stx ()
[(_ exp1 exp2)
(with-syntax ([the-line-number (syntax-line stx)])
(syntax/loc stx
(begin
(printf "~s == ~s : " 'exp1 'exp2)
(if (equal? exp1 exp2)
#lang racket
(require rackunit
rackunit/text-ui)
(define tests
(test-suite
"my suite of tests"
(check-equal? (+ 1 1) 2)
(check-equal? (+ 1 1) 3)))
#lang racket
(require test-engine/racket-tests)
(check-expect 1 1)
(check-expect 3 42)
(test-silence #f)
(test)