package core_kernel
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
Industrial strength alternative to OCaml's standard library
Install
dune-project
Dependency
Authors
Maintainers
Sources
v0.14.2.tar.gz
sha256=66f5353964d35a994ec7fdc88fe60ae5d497ac89a8042786f3e37d9e2202ce4b
md5=ede2f6d22eaa8320f88bac67d41b5cff
doc/src/core_kernel/sequence.ml.html
Source file sequence.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 70open! Import include Base.Sequence include Bin_prot.Utils.Make_binable1_without_uuid [@alert "-legacy"] (struct module Binable = struct type 'a t = 'a list [@@deriving bin_io] end type 'a t = 'a Base.Sequence.t let of_binable = Base.Sequence.of_list let to_binable = Base.Sequence.to_list end) module Step = struct include Step type ('a, 's) t = ('a, 's) Step.t = | Done | Skip of 's | Yield of 'a * 's [@@deriving bin_io] end module Merge_with_duplicates_element = struct include Merge_with_duplicates_element type ('a, 'b) t = ('a, 'b) Merge_with_duplicates_element.t = | Left of 'a | Right of 'b | Both of 'a * 'b [@@deriving bin_io] end module type Heap = sig type 'a t val create : compare:('a -> 'a -> int) -> 'a t val add : 'a t -> 'a -> 'a t val remove_min : 'a t -> ('a * 'a t) option end let merge_all (module Heap : Heap) seqs ~compare = let module Merge_all_state = struct type 'a t = { heap : ('a * 'a Base.Sequence.t) Heap.t ; not_yet_in_heap : 'a Base.Sequence.t list } [@@deriving fields] let create = Fields.create end in unfold_step ~init: (Merge_all_state.create ~heap:(Heap.create ~compare:(Base.Comparable.lift compare ~f:fst)) ~not_yet_in_heap:seqs) ~f:(fun { heap; not_yet_in_heap } -> match not_yet_in_heap with | seq :: not_yet_in_heap -> (match Expert.next_step seq with | Done -> Skip { not_yet_in_heap; heap } | Skip seq -> Skip { not_yet_in_heap = seq :: not_yet_in_heap; heap } | Yield (elt, seq) -> Skip { not_yet_in_heap; heap = Heap.add heap (elt, seq) }) | [] -> (match Heap.remove_min heap with | None -> Done | Some ((elt, seq), heap) -> Yield (elt, { heap; not_yet_in_heap = [ seq ] }))) ;;
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>