package octez-libs
A package that contains multiple base libraries used by the Octez suite
Install
Dune Dependency
Authors
Maintainers
Sources
tezos-octez-v20.1.tag.bz2
sha256=ddfb5076eeb0b32ac21c1eed44e8fc86a6743ef18ab23fff02d36e365bb73d61
sha512=d22a827df5146e0aa274df48bc2150b098177ff7e5eab52c6109e867eb0a1f0ec63e6bfbb0e3645a6c2112de3877c91a17df32ccbff301891ce4ba630c997a65
doc/src/octez-libs.mec/iterator.ml.html
Source file iterator.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
type bit = int module Bit = struct type t = {f : unit -> bit option; size : int; mutable i : int} let of_bytes_le b = let length = Bytes.length b in if length = 0 then {f = (fun () -> None); size = 0; i = 0} else let current_byte_int = ref (Bytes.get_uint8 b 0) in let i = ref 0 in let j = ref 0 in let rec f () : bit option = if !i = length - 1 && !j = 8 then None else if !j = 8 then ( i := !i + 1 ; current_byte_int := Bytes.get_uint8 b !i ; j := 0 ; f ()) else let b = !current_byte_int mod 2 in j := !j + 1 ; current_byte_int := !current_byte_int lsr 1 ; Some b in {f; size = length * 8; i = 0} let is_processed {f = _; size; i} = size = i let of_bool_list bs = let bs_ref = ref bs in let length = List.length bs in if length = 0 then {f = (fun () -> None); size = length; i = 0} else let f () = match !bs_ref with | [] -> None | b :: bs -> bs_ref := bs ; Some (if b then 1 else 0) in {f; size = length; i = 0} let next iterator = if is_processed iterator then None else let res = iterator.f () in iterator.i <- iterator.i + 1 ; res let get_chunk iterator ?(default = 0) n = if is_processed iterator then List.init n (fun _ -> default) else List.init n (fun _ -> Option.value (next iterator) ~default) end
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>