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
raco setup: --- installing collections --- | |
raco setup: --- post-installing collections --- | |
raco setup: post-installing: <pkgs>/gui-lib/mred | |
raco setup: post-installing: <pkgs>/gui-lib/racket/gui | |
raco setup: post-installing: <pkgs>/mzcom | |
raco setup: post-installing: <pkgs>/mzscheme-lib/mzscheme | |
raco setup: post-installing: <pkgs>/racket-doc/help | |
raco setup: --- checking package dependencies --- | |
raco setup: package declares no dependencies: "abnf" | |
raco setup: package declares no dependencies: "set" |
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
(define-syntax (myapply stx) | |
(define (is-underscore? x) (equal? '_ (syntax->datum x))) | |
(syntax-case stx () | |
[(_ fun . args) | |
(let* ([missing-ids (dar (filter is-underscore? (syntax->list #'args)))] | |
[new-ids (dar (take (length missing-ids) (generate-temporaries #'args)))] | |
[new-args (dar (replace-if is-underscore? (syntax->list #'args) new-ids))]) | |
(with-syntax ([(new-arg ...) new-args] | |
[(new-id ...) new-ids]) | |
#'(lambda (new-id ...) (fun new-arg ...))))])) |
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-object bitmap% 400 400)) | |
(define dc (new bitmap-dc% [bitmap bm])) | |
(define p (new dc-path%)) | |
(send p move-to 300 200) | |
(send p arc 100 100 200 200 0 (* 2 pi)) | |
(send p line-to 400 200) |
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 (for-syntax syntax/parse) pict unstable/gui/pict) | |
(define-syntax defv (make-rename-transformer #'define-values)) | |
(define-syntax defm (make-rename-transformer #'match-define)) | |
(define-syntax def (make-rename-transformer #'define)) | |
(define-match-expander color: | |
(λ (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 | |
(struct foo: (x y) | |
#:reflection-name 'foo | |
#:transparent) | |
(define (make-foo x y) | |
(match* (x y) | |
[((? number?) (? number?)) (foo: x y)] | |
[(_ _) (error 'foo/test "elements must be numbers")])) |
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 | |
(module constants racket | |
(provide e pi) | |
(define e 2.1718281828) | |
(define pi (* 355/113 1.0))) | |
(require 'constants) | |
pi | |
; (set! pi (+ pi 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 | |
(module+ constants (provide c) (define c 42)) | |
(require (submod "." constants)) ; incorrect! | |
c | |
(set! c (+ c 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 | |
(define-syntax c | |
(make-set!-transformer | |
(lambda (stx) | |
(syntax-case stx (set!) | |
[(set! id v) #'(error 'set! "c is immutable")] | |
[id (identifier? #'id) #'42])))) | |
c | |
(set! c 43) |
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 | |
(define ns (make-base-namespace)) | |
(define port (open-input-string "(define x 41) (+ x 1)")) | |
(for ([expr (in-port read port)]) | |
(displayln (eval expr ns))) |
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 racket/list)) | |
(define-syntax (foo stx) | |
(define (quote-it stx) (list 'quote stx)) | |
(define name+xs (syntax->list stx)) | |
(define name (first name+xs)) ; unused (is foo) | |
(define xs (rest name+xs)) | |
(define result-as-list (cons 'vector (map quote-it xs))) | |
(datum->syntax stx result-as-list)) |