package picos_std
Sample libraries for Picos
Install
Dune Dependency
Authors
Maintainers
Sources
picos-0.5.0.tbz
sha256=862d61383e2df93a876bedcffb1fd1ddc0f96c50b0e9c07943a2aee1f0e182be
sha512=87805379017ef4a7f2c11b954625a3757a0f1431bb9ba59132202de278b3e41adbe0cdc20e3ab23b7c9a8c5a15faeb7ec79348e7d80f2b14274b00df0893b8c0
doc/src/picos_std.sync/q.ml.html
Source file q.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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
type ('a, _) tdt = | Nil : ('a, [> `Nil ]) tdt | Cons : { value : 'a; mutable next : 'a spine } -> ('a, [> `Cons ]) tdt and 'a spine = S : ('a, [< `Nil | `Cons ]) tdt -> 'a spine [@@unboxed] type 'a cons = ('a, [ `Cons ]) tdt external as_cons : 'a spine -> 'a cons = "%identity" type ('a, _) queue = | Zero : ('a, [> `Zero ]) queue | One : { head : 'a cons; tail : 'a cons; cons : 'a cons; } -> ('a, [> `One ]) queue type ('a, 'n) one = ('a, ([< `One ] as 'n)) queue type 'a t = T : ('a, [< `Zero | `One ]) queue -> 'a t [@@unboxed] let[@inline] singleton value = let cons = Cons { value; next = S Nil } in T (One { head = cons; tail = cons; cons }) let[@inline] exec (One o : (_, _) one) = if o.tail != o.cons then let (Cons tl) = o.tail in if tl.next != S o.cons then tl.next <- S o.cons let[@inline] snoc (One o as t : (_, _) one) value = exec t; let cons = Cons { value; next = S Nil } in T (One { head = o.head; tail = o.cons; cons }) let[@inline] add t value = match t with T Zero -> singleton value | T (One _ as o) -> snoc o value let[@inline] head (One { head = Cons hd; _ } : (_, _) one) = hd.value let[@inline] tail (One o as t : (_, _) one) = exec t; if o.head == o.cons then T Zero else let (Cons hd) = o.head in T (One { head = as_cons hd.next; tail = o.cons; cons = o.cons }) let rec iter (Cons cons_r : _ cons) action = action cons_r.value; match cons_r.next with S Nil -> () | S (Cons _ as cons) -> iter cons action let[@inline] iter (One o as t : (_, _) one) action = exec t; iter o.head action let rec find_tail (Cons cons_r as cons : _ cons) = match cons_r.next with S Nil -> cons | S (Cons _ as cons) -> find_tail cons let[@tail_mod_cons] rec reject (Cons cons_r : _ cons) value = if cons_r.value != value then match cons_r.next with | S Nil -> raise_notrace Not_found | S (Cons _ as cons) -> S (Cons { value = cons_r.value; next = reject cons value }) else cons_r.next let remove (One o as t : (_, _) one) value = exec t; match reject o.head value with | S Nil -> T Zero | S (Cons _ as head) -> let tail = find_tail head in T (One { head; tail; cons = tail }) | exception Not_found -> T t
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>