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.
21 lines
747 B
Racket
21 lines
747 B
Racket
#lang racket/base
|
|
(require (for-syntax racket/base br/syntax) racket/class br/define "base.rkt")
|
|
(provide (all-defined-out) (all-from-out "base.rkt"))
|
|
|
|
|
|
(define-macro (test-module . EXPRS)
|
|
#`(module+ test
|
|
(require #,(datum->syntax caller-stx 'rackunit) #,(datum->syntax caller-stx 'racket/serialize))
|
|
. EXPRS))
|
|
|
|
(define index? (λ (x) (and (number? x) (integer? x) (not (negative? x)))))
|
|
|
|
(define key? symbol?)
|
|
(define (keys? x) (and (pair? x) (andmap key? x)))
|
|
|
|
(define (unsigned->signed uint bits)
|
|
(define most-significant-bit-mask (arithmetic-shift 1 (sub1 bits)))
|
|
(- (bitwise-xor uint most-significant-bit-mask) most-significant-bit-mask))
|
|
|
|
(define (signed->unsigned sint bits)
|
|
(bitwise-and sint (arithmetic-shift 1 bits))) |