This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(require racket/pretty) | |
(define list-with-elts | |
(range 100)) | |
(pretty-print-columns 'infinity) | |
(print list-with-elts) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(require racket/pretty) | |
(define list-with-elts | |
(range 100)) | |
(pretty-print list-with-elts) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket/base | |
(require net/url | |
net/uri-codec | |
json) | |
;; Experiments with module-name-resolvers. | |
(define old-module-name-resolver (current-module-name-resolver)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
;; Experiment: interaction between compiled code and a tool. | |
;; | |
;; Typically, 3d syntax is often used here. But let's say we don't | |
;; want 3d syntax. Is there another way? | |
;; | |
;; Idea: when evaluating code, attach a module to the evaluating | |
;; namespace that the code and the tool share. | |
;; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(require (for-syntax syntax/boundmap | |
syntax/parse)) | |
(begin-for-syntax | |
(define const-table (make-free-identifier-mapping))) | |
(define-syntax (define-int-constant stx) | |
(syntax-parse stx |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
;; The racket/draw libraries provide imperative drawing functions. | |
;; http://docs.racket-lang.org/draw/index.html | |
(require racket/draw) | |
;; To create an image with width and height, use the make-bitmap | |
;; function. | |
;; For example, let's make a small image here: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(require racket/draw) | |
;; flood-fill: bitmap<%> number number color color -> void | |
;; An example of flood filling a bitmap. | |
;; | |
;; We'll use a raw, byte-oriented interface here for demonstration | |
;; purposes. Racket does provide get-pixel and set-pixel functions | |
;; which work on color% structures rather than bytes, but it's useful |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(require parser-tools/lex) | |
(require (prefix-in : parser-tools/lex-sre)) | |
(require racket/port) | |
(define a-lexer | |
(lexer ("a" `(A ,lexeme)) | |
((eof) eof))) | |
;; produce a list of pairs for all the A tokens in the string "aa" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
(require racket/draw) | |
(define bm (make-bitmap 640 480)) | |
(define dc (send bm make-dc)) | |
(define pixs (make-hash)) | |
(define black (make-object color% 0 0 0)) | |
(define (plot row col) | |
(hash-set! pixs (list col row) 1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket/base | |
(require racket/port | |
racket/contract) | |
(provide (contract-out [modularize-input-port (-> | |
#:name symbol? | |
#:ip input-port? | |
#:lang symbol? | |
input-port?)])) |