Skip to content

Commit

Permalink
Revert
Browse files Browse the repository at this point in the history
  • Loading branch information
davesnx committed Aug 9, 2023
1 parent c601d66 commit 2472ba0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions packages/belt/src/belt_Array.ml
Original file line number Diff line number Diff line change
Expand Up @@ -503,18 +503,19 @@ let reduceWithIndexU a x f =

let reduceWithIndex a x f = reduceWithIndexU a x (fun a b c -> f a b c)

let joinWithU a sep =
let joinWithU a sep toString =
match length a with
| 0 -> ""
| l ->
let lastIndex = l - 1 in
let rec aux i res =
let v = getUnsafe a i in
if i = lastIndex then res ^ v else aux (i + 1) (res ^ v ^ sep)
if i = lastIndex then res ^ toString v
else aux (i + 1) (res ^ toString v ^ sep)
in
aux 0 ""

let joinWith a sep = joinWithU a sep
let joinWith a sep toString = joinWithU a sep (fun x -> toString x)
let initU n f = Stdlib.Array.init n f
let init n f = initU n (fun i -> f i)

Expand Down
4 changes: 2 additions & 2 deletions packages/belt/src/belt_Array.mli
Original file line number Diff line number Diff line change
Expand Up @@ -549,9 +549,9 @@ val reduceWithIndex : 'a t -> 'b -> ('b -> 'a -> int -> 'b) -> 'b
]}
*)

val joinWithU : string t -> string -> string
val joinWithU : 'a t -> string -> (('a -> string)[@bs]) -> string

val joinWith : string t -> string -> string
val joinWith : 'a t -> string -> ('a -> string) -> string
(** [joinWith xs sep toString]
Concatenates all the elements of [xs] converted to string with [toString], each separated by [sep], the string
Expand Down

0 comments on commit 2472ba0

Please sign in to comment.