You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
878 B
Racket
34 lines
878 B
Racket
#lang racket/base
|
|
(require (for-syntax racket/base racket/syntax))
|
|
|
|
(provide (all-defined-out))
|
|
|
|
(define-syntax (report stx)
|
|
(syntax-case stx ()
|
|
[(_ expr) #'(report expr expr)]
|
|
[(_ expr name)
|
|
#'(begin
|
|
(displayln (format "~a = ~v" 'name expr) (current-error-port))
|
|
expr)]))
|
|
|
|
|
|
(define-syntax (report* stx)
|
|
(syntax-case stx ()
|
|
[(_ expr ...) (datum->syntax stx `(begin ,@(map (λ(arg) `(report ,arg)) (syntax->datum #'(expr ...)))))]))
|
|
|
|
|
|
(define-syntax-rule (repeat num expr ...)
|
|
(for/last ([i (in-range num)])
|
|
expr ...))
|
|
|
|
|
|
(define-syntax-rule (time-repeat num expr ...)
|
|
(time (repeat num expr ...)))
|
|
|
|
|
|
(define-syntax (time-repeat* stx)
|
|
(syntax-case stx ()
|
|
[(_ num expr ...)
|
|
(let ([num (syntax->datum #'num)])
|
|
(datum->syntax stx `(values ,@(map (λ(arg) `(time-repeat ,num ,arg)) (syntax->datum #'(expr ...))))))]))
|