syndicate-rkt/syndicate/support/bytes.rkt

15 lines
403 B
Racket
Raw Normal View History

; SPDX-License-Identifier: LGPL-3.0-or-later
2021-06-04 09:35:27 +00:00
; SPDX-FileCopyrightText: 2010-2021 Tony Garnock-Jones <tonyg@leastfixedpoint.com>
2020-04-27 18:27:48 +00:00
#lang racket/base
(provide bytes-index)
;; This should probably be in the standard library.
(define (bytes-index bs b)
(define len (bytes-length bs))
(let loop ((i 0))
(cond [(= i len) #f]
[(eqv? (bytes-ref bs i) b) i]
[else (loop (+ i 1))])))