package incremental
Library for incremental computations
Install
Dune Dependency
Authors
Maintainers
Sources
v0.17.0.tar.gz
sha256=bcd6da0c70d9f0b0d528b16d8faf800dd92cd45dca817f4b750628921671e8e0
doc/src/incremental.incremental_step_function/incremental_step_function.ml.html
Source file incremental_step_function.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
open! Core module Time_ns = struct include Time_ns let sexp_of_t = Time_ns.Alternate_sexp.sexp_of_t end type 'a t = { init : 'a ; steps : (Time_ns.t * 'a) Sequence.t } [@@deriving fields ~getters, sexp_of] let invariant invariant_a { init; steps = _ } = invariant_a init let rec value_internal init steps ~at = match Sequence.next steps with | None -> init | Some ((t, a), steps) -> if Time_ns.( < ) at t then init else value_internal a steps ~at ;; let value t ~at = value_internal t.init t.steps ~at let constant init = { init; steps = Sequence.empty } let create_exn ~init ~steps = if not (List.is_sorted steps ~compare:(fun (time1, _) (time2, _) -> Time_ns.compare time1 time2)) then raise_s [%message "[Step_function.create_exn] got unsorted times" ~steps:(steps |> List.map ~f:fst : Time_ns.t list)]; { init; steps = steps |> Sequence.of_list } ;; let create_from_sequence ~init ~steps = { init; steps }
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>