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 | |
(provide tagged-begin) | |
;;; INTRODUCTION | |
; This is a little macro that resembles the Common Lisp tagbody construct | |
; <http://www-2.cs.cmu.edu/Groups/AI/html/hyperspec/HyperSpec/Body/speope_tagbody.html#tagbody> | |
; See also "Applications of Continuations" of Daniel P. Friedman. | |
;;; MOTIVATION |
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-syntax (my-for/first stx) | |
(syntax-case stx () | |
[(_ (for-clause ...) . defs+exprs) | |
(syntax/loc stx | |
(let-values ([(val _) | |
(for/fold ([val #f] [stop? #f]) | |
(for-clause ... #:unless stop?) | |
(begin | |
(define x (let () . defs+exprs)) |
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
(for/fold ([val #f] [stop? #f]) | |
(#:unless stop? | |
[x '(1 3 5 7 4 9 6)] | |
#:when (even? x)) | |
(values x #t)) |
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 typed/racket | |
[integer-sqrt/remainder (Natural Natural -> Natural)]) | |
integer-sqrt/remainder | |
---- | |
racket-math/racket/collects/racket/contract/private/blame.rkt:89:0: integer-sqrt/remainder: broke its contract | |
promised a procedure that accepts 2 mandatory arguments without any keywords, produced: #<procedure:integer-sqrt/remainder> | |
in: (recursive-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
;; The first three lines of this file were inserted by DrRacket. They record metadata | |
;; about the language level of this file in a form that our tools can easily process. | |
#reader(lib "htdp-beginner-reader.ss" "lang")((modname pacman) (read-case-sensitive #t) (teachpacks ((lib "image.ss" "teachpack" "2htdp") (lib "universe.ss" "teachpack" "2htdp"))) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ((lib "image.ss" "teachpack" "2htdp") (lib "universe.ss" "teachpack" "2htdp"))))) | |
;;; Inspired by http://www.khanacademy.org/cs/chompy-and-friends/882986876 | |
(define PACMAN-RADIUS 50) | |
(define pacman | |
(overlay/offset |
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-syntax (foo stx) | |
(syntax-case stx () | |
[(foo x) | |
(let ([a (+ 1 2)]) | |
(with-syntax ([a a]) | |
#'(+ x a)))])) | |
(foo 39) |
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 m (- (expt 2 32) 5)) | |
(define a (- (expt 2 32) 333333333)) | |
(define rand | |
(let ([xn 1]) | |
(λ () | |
(set! xn (modulo (* a xn) m)) | |
xn))) |
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 | |
;;; | |
;;; How to take a screenshot on OS X | |
;;; -- Jens Axel Søgaard | |
;;; | |
;;; This gist illustrates how to work with OS X | |
;;; system calls in order to take a screen shot. | |
;;; |
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 | |
;;; | |
;;; How to take a screenshot on OS X | |
;;; -- Jens Axel Søgaard | |
;;; | |
;;; This gist illustrates how to work with OS X | |
;;; system calls in order to take a screen shot. | |
;;; | |
(require racket/draw |
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 | |
(require ragg/examples/simple-line-drawing/lexer | |
ragg/examples/simple-line-drawing/grammar | |
syntax/parse | |
(for-syntax syntax/parse) | |
(for-syntax racket/base)) | |
(define-syntax (define-datums stx) | |
(syntax-parse stx |
OlderNewer