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 mbox ([v #:mutable])) | |
| (define (box x) (mbox x)) | |
| (define (unbox x) | |
| (cond [(ip? x) | |
| (define imp? (vector-ref (ip-m x) 2)) | |
| (define ub (vector-ref (ip-m x) 0)) |
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 racket/syntax)) | |
| (provide define-inline) | |
| (define-syntax (define-inline stx) | |
| (syntax-parse stx | |
| [(_ (i:id . args) (~optional j:id #:defaults ([j (format-id #'i "~a-inline" #'i)])) rhs) | |
| #'(begin |
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
| cpu time: 2269 real time: 2270 gc time: 1416 | |
| cpu time: 416 real time: 417 gc time: 0 | |
| cpu time: 184 real time: 184 gc time: 0 |
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 syntax/parse/define) | |
| (define-simple-macro (if (~seq test result) ... final) | |
| (cond [test result] ... [else final])) | |
| (if (even? 7) "seven" (odd? 8) "eight" "neither") |
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 dict "/etc/dictionaries-common/words") | |
| (define (choose l) (list-ref l (random (length l)))) | |
| (define words (for/list ([i (file->lines dict)] | |
| #:when (regexp-match? "^[a-z]*$" i) | |
| #:when (3 . < . (string-length i)) | |
| #:when (10 . > . (string-length i))) | |
| i)) |
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/load | |
| (module o racket | |
| (define c% (class object% (init-field p) (define/public (m) (p 0)) (super-new))) | |
| (provide c%)) | |
| (module m typed/racket | |
| (require/typed 'o [c% (Class () ([p Any]) ([m (-> Any)]))]) | |
| (: f : String -> String) |
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/load | |
| (module m typed/racket | |
| (define: v : Any (exn "" (current-continuation-marks))) | |
| (provide v)) | |
| (module n racket | |
| (require 'm) | |
| v) |
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/private/sc)) | |
| (define-syntax (pvar stx) | |
| (syntax-case stx () | |
| [(_ i) | |
| (identifier? #'i) | |
| (let ([v (syntax-local-value #'i (λ _ #f))]) | |
| (unless (syntax-pattern-variable? v) |
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/load | |
| (module m typed/racket | |
| (: f : String -> String) | |
| (define (f x) x) | |
| (provide f)) | |
| (module n racket | |
| (begin-for-syntax | |
| (require typed-racket/utils/tc-utils) |
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
| `( | |
| (start #f) | |
| (visit | |
| ,(datum->syntax | |
| #f | |
| '(module anonymous-module racket | |
| (#%module-begin | |
| (require racket/place/distributed racket/place) | |
| (provide hello-world) | |
| (define (hello-world) |