This file contains 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/unsafe/ops) | |
(define v (vector 0)) | |
(unsafe-vector-ref v 50) |
This file contains 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 | |
(require/typed 2htdp/image | |
[#:opaque Image image?] | |
[circle (Number String String -> Image)]) |
This file contains 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 node (x l r) #:transparent) | |
(define/match (size t) | |
[(#f) 0] | |
[((node x l r)) (+ 1 (size l) (size r))]) | |
(define braun/c | |
(flat-rec-contract braun/c | |
(or/c #f |
This file contains 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 N 100000000) | |
(define K 50000000) | |
(time | |
(for/fold ([c 0]) ([i (in-range N)] #:break (not c)) | |
(if (= i K) | |
#f | |
(add1 c)))) |
This file contains 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/base | |
(require racket/cmdline) | |
(: opt-verbose-mode (Parameterof Boolean)) | |
(define opt-verbose-mode (make-parameter #f)) | |
(: opt-max-size (Parameterof Real)) | |
(define opt-max-size (make-parameter 0)) |
This file contains 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 | |
#| | |
The paint-by-numbers-canavas% class accepts two initalization | |
arguments. They must be lists of lists of numbers and they must be the | |
same length. paint-by-numbers-canvas% objects accepts four methods: | |
set-rect : (int int (union 'on 'off 'unknown) -> void) | |
Sets the grid point specified by the first two arguments to the third. | |
The coordinates are from the top-left and the x coordinate comes first. |
This file contains 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 "foo.rkt") | |
(define ns (make-base-namespace)) | |
(define v* | |
(let () | |
(parameterize ([current-namespace ns]) | |
(dynamic-require "foo.rkt" 'v)))) | |
(x? v*) ;; should be #f |
This file contains 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-struct contract-property [ name | |
first-order | |
projection | |
stronger | |
generate | |
exercise | |
val-first-projection | |
list-contract? ] |
This file contains 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 (average l) | |
(define len (length l)) | |
(define sum (apply + l)) | |
(display (/ len l))) | |
(average (list 1 2 3 400 500 600)) |
This file contains 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 (mandelbrot/old iterations x y n) | |
(let ([ci (- (/ (* 2.0 y) n) 1.0)] | |
[cr (- (/ (* 2.0 x) n) 1.5)]) | |
(let loop ([i 0] [zr 0.0] [zi 0.0]) | |
(if (> i iterations) | |
i | |
(let ([zrq (* zr zr)] | |
[ziq (* zi zi)]) |