Welcome to Racket v7.0.
> (for/hash ([x 10]) (values x x))
'#hash((0 . 0)
(1 . 1)
(2 . 2)
(3 . 3)
(4 . 4)
(5 . 5)
(6 . 6)
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 | |
| #| | |
| A Hack to remote control Spotify from Racket. | |
| It pretty reliably will crash DrRacket if run. | |
| Works better if require'd from another module, or run from command line. | |
| |# |
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/class | |
| racket/draw | |
| racket/match | |
| threading | |
| (only-in math pi)) | |
| (struct draw (perform x0 y0 x1 y1) |
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/class | |
| racket/gui | |
| racket/struct) | |
| (struct message | |
| (text size) | |
| #:methods gen:custom-write | |
| [(define (write-proc v outp mode) |
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 out (tee "test")) | |
| > (fprintf out "test~%") | |
| test | |
| > (fprintf out "test~%") | |
| test | |
| > (fprintf out "test~%") | |
| test | |
| > (for ([x 10]) (fprintf out "test ~a~%" x)) | |
| test 0 | |
| test 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) | |
| (define (tee filename) | |
| (let ([file-out (open-output-file filename)] | |
| [stdout (current-output-port)]) | |
| (let-values ([(inp outp) (make-pipe)]) | |
| (thread | |
| (lambda () |
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/class | |
| racket/gui) | |
| (define frame | |
| (new frame% [label "Tabs!"])) | |
| (define (change-tab tp event) | |
| (when (eq? (send event get-event-type) 'tab-panel) |
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 foo% | |
| (class object% | |
| (init-field f) | |
| (define/public (get-f) f) | |
| (super-new))) | |
| (define foo (make-object foo% 42)) |
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 | |
| #| | |
| Crude hack when I have to repeatedly copy a bunch of things and then want | |
| to paste them in one go. | |
| Very imperative! | |
| Such power! |
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/match | |
| racket/struct | |
| (rename-in data/heap | |
| [heap-remove-min! -heap-remove-min!])) | |
| (define (heap-empty? h) | |
| (zero? (heap-count h))) |