rJVItB55.5.0+dev0-2025-04-28/%Array!tA;!a@@A@A%arrayB@@@@@@@@@6../../stdlib/array.mli^^@@@@%Array@@A@&length@!a@B@@@@#int@@@@@-%array_lengthAA @@@$a%a@@#A@@#get@:!a@B@@@@@$@@@@@@@/%array_safe_getBA#@@@@GdWWHdW@@FB@@#set@]!a@B@@@@@G@@@@$unit@@@@@@@@@ʐ/%array_safe_setCAN@@@@@smtm@@rC@@$make@e@@@@!a@B@ @@@@@@@Ґ/caml_array_makeBAr@@@@uu @@D@@,create_float@@@@%float@@@@@@@@ِ7caml_array_create_floatAA@@@B > >B > @@E@@$init@@@@@@@@@!a@B@@@ @@@@@@@@G  G  @@F@@+make_matrix@@@@@@@@@!a@B@ @@@@@@@@@@@@@Q  Q  @@G@@+init_matrix@@@@@@@@@@@@@@@@@!a@B@@@@@>C@@@@@@@@@@@@@?^@^8@@>H@@&append@U!a@ B@@@@@c@@@i@@@@@@@@dmDDemDq@@cI@@&concat@$list!a@B@ @@@ @@@ @@@@@@s--s-S@@J@@#sub@!a@ B@@@@@@@@@@@@@@@@@@@@@@vv@@K@@$copy@!a@(B@!@@@# @@@%@@&@@@L@@$fill@!a@4B@)@@@+@@@@,@@@@-@@@@.@@/@@0@@1@@2@ppp@@M@@$blit @!a@DB@5@@@7@@@@8@'@@@:@ @@@;@@@@<@@@=@@>@@?@@@@@A@@B@5tt6@@4N@@'to_list!@K!a@LB@E@@@G @@@I@@J@RS@@QO@@'of_list"@!a@TB@M@@@Ot @@@Q@@R@op@@nP@@%equal#@@!a@bB@U@$bool@@@V@@W@@X@@@@Z@@@@\@@@]@@^@@_@@`@@@Q@@'compare$@@!a@pB@c@@@@d@@e@@f@Ġ@@@h@Š@@@j@@@k@@l@@m@@n@@@R@@$iter%@@!a@zB@qz@@@r@@s@Ƞ@@@u@@@v@@w@@x@-@@S@@%iteri&@@@@@{@!a@B@|@@@}@@~@@@̠@@@@@@@@@@@ @@T@@#map'@@!a@B@!b@B@@@@EΠ@@@KϠ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@!a@B@@@@@!b@B@@@@@@@@@@@@@@@@;/j/j;/j/@@i@@$sort<@@!a@B@@@@@@@@@@@@@m@@@@@@@@C00C00@@j@@+stable_sort=@@!a@B@@@@@@@@@@@@@@@@@@@@@\44\45@@k@@)fast_sort>@@!a@B@@ @@@@@@@@' @@@ @@@@@@@@'f66(f66@@&l@@'shuffle?$rand@ @@@" @@@@@@M!a@B@@@@@@@@@@@@Sj7(7(Tk767@@Rm@@&to_seq@i!a@ B@@@@&Stdlib#Seq!t@@@ @@ @ux9'9'vx9'9H@@tn@@'to_seqi@!a@ B@ @@@ &Stdlib#Seq!t@@@@ @@@ @@@ @@ @}99}9: @@o@@&of_seq@&Stdlib#Seq!t!a@ B@ @@@  @@@ @@ @::::@@p@@*unsafe_get@!a@ B@ @@@ @@@@ @@ @@ 1%array_unsafe_getBAà@@@@GGGG@@q@@*unsafe_set@!a@ B@ @@@ @@@@ @@@@ @@ @@ @@ 1%array_unsafe_setCA@@@@@GGGH@@r@@ӱ*FloatarrayB@&create@ @@@ *floatarray@@@ !@@ "6caml_floatarray_createAA@@@2H/H13H/Ho@@1s@@&length@@@@ #)@@@ $@@ %2%floatarray_lengthAA(@@@KHpHrLHpH@@Jt@@#get@. @@@ &@D!@@@ '"@@@ (@@ )@@ *4%floatarray_safe_getBAH@@@@lHHmHH@@ku@@#set@O#@@@ +@e$@@@ ,@%@@@ -#&@@@ .@@ /@@ 0@@ 14%floatarray_safe_setCAp@@@@@HHHI>@@v@@*unsafe_get@x'@@@ 2@(@@@ 3)@@@ 4@@ 5@@ 66%floatarray_unsafe_getBA@@@@I?IAI?I@@w@@*unsafe_set@*@@@ 7@+@@@ 8@$,@@@ 9m-@@@ :@@ ;@@ <@@ =6%floatarray_unsafe_setCA@@@@@IIII@@x@@@@HHII@y@@@@31Array operations.@ L The labeled version of this module can be used as described in the )StdLabels@@( module.@@@@@@@@@@@@A6../../stdlib/array.mli#'Array.t3 An alias for the type of arrays.@@@@@@@@@@@@ @@A @  @@,Array.length3 :Return the length (number of elements) of the given array.@@@@@@@@@@@@ @  @@@@)Array.get3'get a n< returns the element number !n* of array !a D. The first element has number 0. The last element has number ,length a - 18. You can also write %a.(n), instead of 'get a n!.@@@@@@@@0Invalid_argument#if !n; is outside the range 0 to .(length a - 1)!.@@@@@ *@C +@F @@@@ )Array.set3)set a n x0 modifies array !a ' in place, replacing element number !n& with !x8. You can also write *a.(n) <- x, instead of )set a n x!.@@@@@@@@0Invalid_argument#if !n; is outside the range 0 to ,length a - 1!.@@@@@ L@ M@ B@ N@@@@ 4*Array.make3(make n x ! returns a fresh array of length !n6, initialized with !x M. All the elements of this new array are initially physically equal to !x6 (in the sense of the "== ! predicate). Consequently, if !x L is mutable, it is shared among all elements of the array, and modifying !x T through one of the array entries will modify all other entries at the same time.@@@@@@@@0Invalid_argument#if %n < 0$ or 8n > Sys.max_array_length5. If the value of !x > is a floating-point number, then the maximum size is only 8Sys.max_array_length / 2!.@@@@@ z@ {@ w@@@@ h2Array.create_float3.create_float n ' returns a fresh float array of length !n>, with uninitialized data.@@@@$4.03@@@@@@@ t@ u@@@@ b*Array.init3(init n f ! returns a fresh array of length !n9, with element number !i> initialized to the result of #f i5. In other terms, (init n f: tabulates the results of !f % applied in order to the integers !0$ to #n-1!.@@@@@@@@0Invalid_argument#if %n < 0$ or 8n > Sys.max_array_length;. If the return type of !f$ is %float #, then the maximum size is only 8Sys.max_array_length / 2!.@@@@@ @_ @b @@@@ 1Array.make_matrix37make_matrix dimx dimy e N returns a two-dimensional array (an array of arrays) with first dimension $dimx9 and second dimension $dimy K. All the elements of this new matrix are initially physically equal to !e2. The element (#x,y.) of a matrix !m " is accessed with the notation )m.(x).(y)!.@@@@@@@@0Invalid_argument#if $dimx$ or $dimy is negative or greater than 4Sys.max_array_length@@5. If the value of !e > is a floating-point number, then the maximum size is only 8Sys.max_array_length / 2!.@@@@@ @ @ @ @@@@ ՠ1Array.init_matrix37init_matrix dimx dimy f Q returns a two-dimensional array (an array of arrays) with first dimension $dimx6 and second dimension $dimy !, where the element at index (#x,y6) is initialized with %f x y2. The element (#x,y.) of a matrix !m " is accessed with the notation )m.(x).(y)!.@@@@#5.2@@@0Invalid_argument#if $dimx$ or $dimy is negative or greater than 4Sys.max_array_length@@;. If the return type of !f$ is %float #, then the maximum size is only 8Sys.max_array_length / 2!.@@@@@ /@* 0@- ,@0 (@@@@ ,Array.append3,append v1 v2 E returns a fresh array containing the concatenation of the arrays "v1% and "v2!.@@@@@@@@0Invalid_argument&if ,length v1 + length v2 > Sys.max_array_length!.@@@@@ &@Z '@] @@@@ ,Array.concat3(Same as 6D@ $, but concatenates a list of arrays.@@@@@@@@@@@@ @r @@@@ )Array.sub3-sub a pos len ! returns a fresh array of length #len $, containing the elements number #pos$ to -pos + len - 1- of array !a!.@@@@@@@@0Invalid_argument#if #pos% and #len ) do not designate a valid subarray of !a1; that is, if 'pos < 0%, or 'len < 0%, or 4pos + len > length a!.@@@@@ I@ J@ ?@ ;@@@@ 2*Array.copy3© a3 returns a copy of !a <, that is, a fresh array containing the same elements as !a!.@@@@@@@@@@@@ B@ C@@@@ 3*Array.fill30fill a pos len x4 modifies the array !a6 in place, storing !x4 in elements number #pos$ to -pos + len - 1!.@@@@@@@@0Invalid_argument#if #pos% and #len ) do not designate a valid subarray of !a!.@@@@@ g@, h@/ ]@2 Y@5 l@@@@ R*Array.blit3 blit src src_pos dst dst_pos len( copies #len8 elements from array #src=, starting at element number 'src_pos+, to array #dst , starting at element number 'dst_pos . It works correctly even if #src% and #dst F are the same array, and the source and destination chunks overlap.@@@@@@@@0Invalid_argument#if 'src_pos% and #len ) do not designate a valid subarray of #src(, or if 'dst_pos% and #len ) do not designate a valid subarray of #dst!.@@@@@ @ @ @ @ @ @@@@ -Array.to_list3)to_list a ) returns the list of all the elements of !a!.@@@@@@@@@@@@ @ @@@@ -Array.of_list3)of_list l 5 returns a fresh array containing the elements of !l!.@@@@@@@@0Invalid_argument1if the length of !l4 is greater than 4Sys.max_array_length!.@@@@@ @ @@@@ A*comparison*Comparison@@+Array.equal3,equal eq a b$ is $true0 if and only if !a% and !b: have the same length !n- and for all !i% in [!0!;#n-1#], .eq a.(i) b.(i)( is $true!.@@@@#5.4@@@@@@@ @< @? @B @@@@ -Array.compare3/compare cmp a b* compares !a% and !b according to the shortlex order, that is, shorter arrays are smaller and equal-sized arrays are compared in lexicographic order using #cmp5 to compare elements.@@@@#5.4@@@@@@@ @h @k @n @@@@ A@)Iterators@@*Array.iter3(iter f a2 applies function !f # in turn to all the elements of !a:. It is equivalent to -f a.(0); f a.(1); ...; f a.(length a - 1); ()!.@@@@@@@@@@@@ @ @ @@@@  +Array.iteri3(Same as 0D@ }, but the function is applied to the index of the element as first argument, and the element itself as second argument.@@@@@@@@@@@@ @ @ @@@@ )Array.map3'map f a2 applies function !f8 to all the elements of !a 6, and builds an array with the results returned by !f%: /[| f a.(0); f a.(1); ...; f a.(length a - 1) |]!.@@@@@@@@@@@@ @ @ @@@@ 1Array.map_inplace3/map_inplace f a2 applies function !f4 to all elements of !a (, and updates their values in place.@@@@#5.1@@@@@@@ @ @ @@@@ *Array.mapi3(Same as YD@ }, but the function is applied to the index of the element as first argument, and the element itself as second argument.@@@@@@@@@@@@ @ @ @@@@ 2Array.mapi_inplace3(Same as DD@ {, but the function is applied to the index of the element as first argument, and the element itself as second argument.@@@@#5.1@@@@@@@ @3 @6 @@@@ /Array.fold_left32fold_left f init a- computes ,f (... (f (f init a.(0)) a.(1)) ...) a.(n-1)+, where !n< is the length of the array !a!.@@@@@@@@@@@@ @Z @] @` @@@@ 3Array.fold_left_map3-fold_left_map5 is a combination of 6D@% and D@ 2 that threads an accumulator through calls to !f!.@@@@$4.13@@@@@@@ @ @ @ @@@@ 0Array.fold_right33fold_right f a init- computes -f a.(0) (f a.(1) ( ... (f a.(n-1) init) ...))+, where !n< is the length of the array !a!.@@@@@@@@@@@@ @ @ @ @@@@ A@7Iterators on two arrays@@+Array.iter23+iter2 f a b2 applies function !f8 to all the elements of !a( and !b!.@@@@:4.03 (4.05 in ArrayLabels)@@@0Invalid_argument $if the arrays are not the same size.@@@@@ @ @ @ @@@@ *Array.map23*map2 f a b2 applies function !f8 to all the elements of !a( and !b 3, and builds an array with the results returned by !f%: <[| f a.(0) b.(0); ...; f a.(length a - 1) b.(length b - 1)|]!.@@@@:4.03 (4.05 in ArrayLabels)@@@0Invalid_argument $if the arrays are not the same size.@@@@@ @' @* @- @@@@ A@.Array scanning@@-Array.for_all39for_all f [|a1; ...; an|] > checks if all elements of the array satisfy the predicate !f9. That is, it returns !(f a1) && (f a2) && ... && (f an)!.@@@@$4.03@@@@@@@ @T @W @@@@ ,Array.exists38exists f [|a1; ...; an|] I checks if at least one element of the array satisfies the predicate !f:. That is, it returns !(f a1) || (f a2) || ... || (f an)!.@@@@$4.03@@@@@@@ @w @z @@@@ .Array.for_all23(Same as OD@ #, but for a two-argument predicate.@@@@$4.11@@@0Invalid_argument )if the two arrays have different lengths.@@@@@ @ @ @ @@@@ -Array.exists23(Same as OD@ #, but for a two-argument predicate.@@@@$4.11@@@0Invalid_argument )if the two arrays have different lengths.@@@@@ @ @ @ @@@@ w)Array.mem3)mem a set8 is true if and only if !a , is structurally equal to an element of #set3 (i.e. there is an !x$ in #set/ such that /compare a x = 0").@@@@$4.03@@@@@@@ @ @ @@@@ *Array.memq3(Same as >D@ Y, but uses physical equality instead of structural equality to compare array elements.@@@@$4.03@@@@@@@ @  @ @@@@ .Array.find_opt3,find_opt f a ( returns the first element of the array !a " that satisfies the predicate !f%, or $None % if there is no value that satisfies !f2 in the array !a!.@@@@$4.13@@@@@@@ @A @D @@@@ 0Array.find_index3.find_index f a) returns &Some i(, where !i 4 is the index of the first element of the array !a0 that satisfies #f x ", if there is such an element.@0 It returns $None= if there is no such element.@@@@#5.1@@@@@@@ @z @} @@@@ .Array.find_map3,find_map f a) applies !f4 to the elements of !a 8 in order, and returns the first result of the form &Some v%, or $None/ if none exist.@@@@$4.13@@@@@@@ @ @ @@@@ /Array.find_mapi3(Same as (find_map , but the predicate is applied to the index of the element as first argument (counting from 0), and the element itself as second argument.@@@@#5.1@@@@@@@ @ @ @@@@ A@/Arrays of pairs@@+Array.split3?split [|(a1,b1); ...; (an,bn)|]$ is "([|a1; ...; an|], [|b1; ...; bn|])!.@@@@$4.13@@@@@@@ @ @@@@ -Array.combine3 'combine [|a1; ...; an|] [|b1; ...; bn|]$ is 9[|(a1,b1); ...; (an,bn)|],. Raise 0Invalid_argument * if the two arrays have different lengths.@@@@$4.13@@@@@@@ @ @  @@@@ qA5sorting_and_shuffling5Sorting and shuffling@@*Array.sort3 /Sort an array in increasing order according to a comparison function. The comparison function must return 0 if its arguments compare as equal, a positive integer if the first is greater, and a negative integer if the first is smaller (see below for a complete specification). For example, .Stdlib.compare@@ 5 is a suitable comparison function. After calling $sort :, the array is sorted in place in increasing order. $sort V is guaranteed to run in constant heap space and (at most) logarithmic stack space.@ S The current implementation uses Heap Sort. It runs in constant stack space.@ 5 Specification of the comparison function: Let !a2 be the array and #cmp A the comparison function. The following must be true for all !x", !y", !z$ in !a" :" 'cmp x y4 > 0 if and only if 'cmp y x$ < 0@% if 'cmp x y* >= 0 and 'cmp y z+ >= 0 then 'cmp x z% >= 0@@) When $sort* returns, !a h contains the same elements as before, reordered in such a way that for all i and j valid indices of !a" :" /cmp a.(i) a.(j)/ >= 0 if i >= j@@@@@@@@@@@@@@ @ @ @@@@ 정1Array.stable_sort3(Same as D@ , but the sorting algorithm is stable (i.e. elements that compare equal are kept in their original order) and not guaranteed to run in constant heap space.@ W The current implementation uses Merge Sort. It uses a temporary array of length #n/2(, where !n Y is the length of the array. It is usually faster than the current implementation of D@!.@@@@@@@@@@@@ @ @ @@@@ /Array.fast_sort3(Same as АD@$ or =D@ +, whichever is faster on typical input.@@@@@@@@@@@@ @ @ @@@@ ꠕ-Array.shuffle3.shuffle rand a3 randomly permutes !a1's element using $rand A for randomness. The distribution of permutations is uniform.@% $rand= must be such that a call to &rand n A returns a uniformly distributed random number in the range [!0!;#n-1']. *Random.int@@ , can be used for this (do not forget to 0Random.self_init@*initialize@0 the generator).@@@@#5.2@@@@@@@ (@ ( '@ G @@@@ A@4Arrays and Sequences@@,Array.to_seq3 }Iterate on the array, in increasing order. Modifications of the array during iteration will be reflected in the sequence.@@@@$4.07@@@@@@@ @ _ @@@@ -Array.to_seqi3 Iterate on the array, in increasing order, yielding indices along elements. Modifications of the array during iteration will be reflected in the sequence.@@@@$4.07@@@@@@@ @ p @@@@ 砕,Array.of_seq3 "Create an array from the generator@@@@$4.07@@@@@@@ @  @@@@ ֠A1array_concurrency=Arrays and concurrency safety@@ Care must be taken when concurrently accessing arrays from multiple domains: accessing an array will never crash a program, but unsynchronized accesses might yield surprising (non-sequentially-consistent) results.@% B/array_atomicity)Atomicity@@ Every array operation that accesses more than one array element is not atomic. This includes iteration, scanning, sorting, splitting and combining arrays.@ 2 For example, consider the following program: let size = 100_000_000 let a = Array.make size 1 let d1 = Domain.spawn (fun () -> Array.iteri (fun i x -> a.(i) <- x + 1) a ) let d2 = Domain.spawn (fun () -> Array.iteri (fun i x -> a.(i) <- 2 * x + 1) a ) let () = Domain.join d1; Domain.join d2 @ 8 After executing this code, each field of the array !a+ is either !2", !3&, !4$ or !5 k. If atomicity is required, then the user must implement their own synchronization (for example, using 'Mutex.t@@").@% B/array_data_race*Data races@@ If two domains only access disjoint parts of the array, then the observed behaviour is the equivalent to some sequential interleaving of the operations from the two domains.@ . A data race is said to occur when two domains access the same array element without synchronization and at least one of the accesses is a write. In the absence of data races, the observed behaviour is equivalent to some sequential interleaving of the operations from different domains.@ Whenever possible, data races should be avoided by using synchronization to mediate the accesses to the array elements.@ q Indeed, in the presence of data races, programs will not crash but the observed behaviour may not be equivalent to any sequential interleaving of operations from different domains. Nevertheless, even in the presence of data races, a read operation will return the value of some prior write to that location (with a few exceptions for float arrays).@% B:array_data_race_exceptions,Float arrays@@ O Float arrays have two supplementary caveats in the presence of data races.@ 6 First, the blit operation might copy an array byte-by-byte. Data races between such a blit operation and another operation might produce surprising values due to tearing: partial writes interleaved with other operations can create float values that would not exist with a sequential execution.@ " For instance, at the end of let zeros = Array.make size 0. let max_floats = Array.make size Float.max_float let res = Array.copy zeros let d1 = Domain.spawn (fun () -> Array.blit zeros 0 res 0 size) let d2 = Domain.spawn (fun () -> Array.blit max_floats 0 res 0 size) let () = Domain.join d1; Domain.join d2 ) the #res - array might contain values that are neither "0.% nor )max_float!.@ Second, on 32-bit architectures, getting or setting a field involves two separate memory accesses. In the presence of data races, the user may observe tearing on any operation.@@@ @@@A#Seq@@@@@