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) | |
;; draw-rectangle: dc -> void | |
(define (draw-rectangle dc) | |
(send dc set-brush "green" 'solid) | |
(send dc set-pen "blue" 1 'solid) | |
(send dc draw-rectangle 0 10 30 10) | |
(send dc set-pen "red" 3 'solid) | |
(send dc draw-line 0 0 30 30) |
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 | |
(define (post-title s) | |
`(h1 ,s)) | |
(define (post-body . paragraphs) | |
`(div ((class "post-body")) | |
,@(filter (lambda (x) (not (string? x))) paragraphs))) | |
(define (paragraph p) | |
`(p ,p)) |
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 s-exp syntax/module-reader | |
shriphani/lang/semantics |
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/stxparam) | |
(define verbosity-level (make-parameter 0)) | |
(define-syntax (log stx) | |
(syntax-case stx () | |
([_ num msg ...] | |
#`(when (>= (verbosity-level) num) | |
(apply printf (list msg ...)))))) |
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 | |
(define this-namespace (make-base-empty-namespace)) | |
(define (make-repl-namespace [module-path 'racket/base]) | |
(parameterize ([current-namespace this-namespace]) | |
(dynamic-require module-path #f)) | |
(define ns (make-empty-namespace)) | |
(parameterize ([current-namespace ns]) | |
(namespace-attach-module this-namespace module-path) |
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 typed/racket | |
(define-type pixel Integer) | |
(: create-bitmap : Integer Integer (Integer Integer -> pixel) -> (Vectorof (Vectorof pixel))) | |
(define (create-bitmap width height generator) | |
(for/vector: : (Vectorof (Vectorof pixel)) ((y : Integer (in-range height))) | |
(for/vector: : (Vectorof pixel) ((x : Integer (in-range width))) | |
(generator x y)))) |
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/gui/base) | |
;; Defines a dc<%> implementation that can wrap around | |
;; another dc. | |
(define wrapped-dc% | |
(class* object% (dc<%>) | |
(init-field delegate) | |
(super-new) |
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 | |
(provide foo%) | |
(define foo% | |
(class object% | |
(super-new) | |
(define (end-impl) | |
(displayln "not yet")) |
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/parse)) | |
(struct person (name age) #:transparent) | |
;; Accept name and age in any order: | |
(define-syntax (new-person stx) | |
(syntax-parse stx | |
[(_ (~or (~optional ((~datum name) name) #:defaults ([name #'"Jane Doe"])) |
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 racket/gui/base) | |
(define instructions | |
'((move 61.17578125 98.36328125) | |
(curve 62.4765625 99.390625 64.015625 99.90234375 65.7890625 99.90234375) | |
(curve 67.953125 99.90234375 70.05078125 99.40234375 72.078125 98.3984375) | |
(curve 75.49609375 96.734375 77.20703125 94.01171875 77.20703125 90.23046875) | |
(line 77.20703125 85.2734375) | |
(curve 76.453125 85.75390625 75.48828125 86.15234375 74.30078125 86.47265625) |