syndicate-rkt/syndicate/support/bytes.rkt

15 lines
420 B
Racket
Raw Normal View History

2021-06-04 13:56:03 +00:00
;;; SPDX-License-Identifier: LGPL-3.0-or-later
;;; SPDX-FileCopyrightText: Copyright © 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))])))