История изменений
Исправление qaqa, (текущая версия) :
Ну и вообще
(define (whitening in-port out-port)
(let rloop ([bits 0]
[bit 0])
(let ([in (read-u8 in-port)])
(unless (eof-object? in)
(let loop ([mask-shift 0]
[bits bits]
[bit bit])
(cond
[(= mask-shift 8)
(rloop bits bit)]
[(= bit 8)
(write-u8 bits out-port)
(loop mask-shift 0 0)]
[else
(let ([ms (+ mask-shift 2)])
(case (bitwise-and 3 (arithmetic-shift in (- mask-shift)))
[(0 3) (loop ms bits bit)]
[(1) (loop ms bits (+ bit 1))]
[(2) (loop ms
(bitwise-ior bits (arithmetic-shift 1 bit))
(+ bit 1))]))]))))))
Исходная версия qaqa, :
Ну и вообще
(define (whitening in-port out-port)
(let rloop ([bits 0]
[bit 0])
(let ([in (read-u8 in-port)])
(if (eof-object? in) '()
(let loop ([mask-shift 0]
[bits bits]
[bit bit])
(cond
[(= mask-shift 8)
(rloop bits bit)]
[(= bit 8)
(write-u8 bits out-port)
(loop mask-shift 0 0)]
[else
(let ([ms (+ mask-shift 2)])
(case (bitwise-and 3 (arithmetic-shift in (- mask-shift)))
[(0 3) (loop ms bits bit)]
[(1) (loop ms bits (+ bit 1))]
[(2) (loop ms
(bitwise-ior bits (arithmetic-shift 1 bit))
(+ bit 1))]))]))))))