Searching
Scheme Procedure: bytestring-index bytevector pred [start [end]]
Scheme Procedure: bytestring-index-right bytevector pred [start [end]]
Searches bytevector from start to end / from end to start for the first byte that satisfies pred, and returns the index into bytevector containing that byte. In either direction, start is inclusive and end is exclusive. If there are no such bytes, returns #f.
emacs-lisp
(bytestring-index #u8(#x65 #x72 #x83 #x6f) (λ (b) (> b #x7f))) ⇒ 2
(bytestring-index #u8"Beeblebrox" (λ (b) (> b #x7f))) ⇒ #f
(bytestring-index-right #u8"Zaphod" odd?) ⇒ 4Scheme Procedure: bytestring-break bytevector pred
Scheme Procedure: bytestring-span bytevector pred
Returns two values, a bytevector containing the maximal sequence of characters (searching from the beginning of bytevector to the end) that do not satisfy / do satisfy pred, and another bytevector containing the remaining characters.
emacs-lisp
(bytestring-break #u8(#x50 #x4b 0 0 #x1 #x5) zero?)
⇒ #u8(#x50 #x4b) #u8(0 0 #x1 #x5)
(bytestring-span #u8"ABCDefg" (lambda (b) (and (> b 40) (< b 91))))
⇒ #u8"ABCD" #u8"efg"