From: Chris Hanson Date: Wed, 22 Feb 2017 05:38:26 +0000 (-0800) Subject: Implement random-byte-vector in Edwin. X-Git-Tag: mit-scheme-pucked-9.2.12~220^2~25 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=d5169d56278dc7d663327c71cd79dea5dbe97309;p=mit-scheme.git Implement random-byte-vector in Edwin. --- diff --git a/src/edwin/edwin.pkg b/src/edwin/edwin.pkg index 9f3844ebc..aba9dd98a 100644 --- a/src/edwin/edwin.pkg +++ b/src/edwin/edwin.pkg @@ -168,6 +168,7 @@ USA. list->string make-string make-vector-8b + random-byte-vector reverse-string reverse-string! reverse-substring diff --git a/src/edwin/string.scm b/src/edwin/string.scm index a4b599a6f..61256efc1 100644 --- a/src/edwin/string.scm +++ b/src/edwin/string.scm @@ -588,6 +588,14 @@ USA. (char-set? object) (unary-procedure? object))) +(define (random-byte-vector n #!optional state) + (let ((bv (random-bytevector n state)) + (s (make-vector-8b n))) + (do ((i 0 (fix:+ i 1))) + ((not (fix:< i n))) + (vector-8b-set! s i (bytevector-u8-ref bv i))) + s)) + (define (vector-8b->hexadecimal bytes) (define-integrable (hex-char k) (string-ref "0123456789abcdef" (fix:and k #x0F)))