From c7930f21405720f51d74efa9f6f7b9da0132a929 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Wed, 16 Apr 2025 21:31:49 +0100 Subject: [PATCH] Update common submodule Richard W.M. Jones (1): mlstdutils: Implement String.implode --- common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Submodule common e9eea65a..8aed7b6a: diff --git a/common/mlstdutils/std_utils.ml b/common/mlstdutils/std_utils.ml index 86b21a7c..1177ff69 100644 --- a/common/mlstdutils/std_utils.ml +++ b/common/mlstdutils/std_utils.ml @@ -256,6 +256,12 @@ module String = struct let map_chars f str = List.map f (explode str) + let implode cs = + let n = List.length cs in + let b = Bytes.create n in + List.iteri (Bytes.unsafe_set b) cs; + Bytes.to_string b + let spaces n = String.make n ' ' let span str accept = diff --git a/common/mlstdutils/std_utils.mli b/common/mlstdutils/std_utils.mli index a39ac5f3..6811b4bc 100644 --- a/common/mlstdutils/std_utils.mli +++ b/common/mlstdutils/std_utils.mli @@ -123,6 +123,8 @@ module String : sig (** Explode a string into a list of characters. *) val map_chars : (char -> 'a) -> string -> 'a list (** Explode string, then map function over the characters. *) + val implode : char list -> string + (** Join list of characters into a single string. *) val spaces : int -> string (** [spaces n] creates a string of n spaces. *) val span : string -> string -> int