* Added bytevector=?

This commit is contained in:
Abdulaziz Ghuloum 2007-05-15 14:37:04 -04:00
parent 1e364d3186
commit 3629e0b0d9
3 changed files with 16 additions and 2 deletions

Binary file not shown.

View File

@ -3,13 +3,13 @@
(export make-bytevector bytevector-length bytevector-s8-ref
bytevector-u8-ref bytevector-u8-set! bytevector-s8-set!
bytevector-copy! u8-list->bytevector bytevector->u8-list
bytevector-fill! bytevector-copy)
bytevector-fill! bytevector-copy bytevector=?)
(import
(except (ikarus)
make-bytevector bytevector-length bytevector-s8-ref
bytevector-u8-ref bytevector-u8-set! bytevector-s8-set!
bytevector-copy! u8-list->bytevector bytevector->u8-list
bytevector-fill! bytevector-copy)
bytevector-fill! bytevector-copy bytevector=?)
(ikarus system $fx)
(ikarus system $pairs)
(ikarus system $bytevectors))
@ -138,6 +138,19 @@
($bytevector-set! dst i ($bytevector-u8-ref src i))
(f src dst ($fxadd1 i) n)])))))
(define bytevector=?
(lambda (x y)
(unless (bytevector? x)
(error 'bytevector=? "~s is not a bytevector" x))
(unless (bytevector? y)
(error 'bytevector=? "~s is not a bytevector" y))
(let ([n ($bytevector-length x)])
(and ($fx= n ($bytevector-length y))
(let f ([x x] [y y] [i 0] [n n])
(or ($fx= i n)
(and ($fx= ($bytevector-u8-ref x i)
($bytevector-u8-ref y i))
(f x y ($fxadd1 i) n))))))))
(define bytevector-copy!
(lambda (src src-start dst dst-start k)

View File

@ -282,6 +282,7 @@
[bytevector-copy! i]
[bytevector-copy i]
[bytevector-fill! i]
[bytevector=? i]
[for-each i r]
[map i r]