@@ -235,6 +235,32 @@ def String.Internal.toArray (b : String) : Array Char :=
235235theorem String.Internal.toArray_empty : String.Internal.toArray "" = #[] := by
236236 simp [toArray]
237237
238+ /--
239+ Converts a string to a list of characters.
240+
241+ Since strings are represented as dynamic arrays of bytes containing the string encoded using
242+ UTF-8, this operation takes time and space linear in the length of the string.
243+
244+ Examples:
245+ * `"abc".toList = ['a', 'b', 'c']`
246+ * `"".toList = []`
247+ * `"\n".toList = ['\n']`
248+ -/
249+ @[extern "lean_string_data", expose]
250+ def toList (s : String) : List Char :=
251+ (String.Internal.toArray s).toList
252+
253+ /--
254+ Converts a string to a list of characters.
255+
256+ Since strings are represented as dynamic arrays of bytes containing the string encoded using
257+ UTF-8, this operation takes time and space linear in the length of the string.
258+
259+ Examples:
260+ * `"abc".toList = ['a', 'b', 'c']`
261+ * `"".toList = []`
262+ * `"\n".toList = ['\n']`
263+ -/
238264@[extern "lean_string_data", expose]
239265def String.data (b : String) : List Char :=
240266 (String.Internal.toArray b).toList
@@ -396,21 +422,6 @@ instance : LE String :=
396422instance decLE (s₁ s₂ : String) : Decidable (s₁ ≤ s₂) :=
397423 inferInstanceAs (Decidable (Not _))
398424
399- /--
400- Converts a string to a list of characters.
401-
402- Since strings are represented as dynamic arrays of bytes containing the string encoded using
403- UTF-8, this operation takes time and space linear in the length of the string.
404-
405- Examples:
406- * `"abc".toList = ['a', 'b', 'c']`
407- * `"".toList = []`
408- * `"\n".toList = ['\n']`
409- -/
410- @[inline, expose]
411- def toList (s : String) : List Char :=
412- s.data
413-
414425theorem _root_.List.isPrefix_of_utf8Encode_append_eq_utf8Encode {l m : List Char} (b : ByteArray)
415426 (h : l.utf8Encode ++ b = m.utf8Encode) : l <+: m := by
416427 induction l generalizing m with
0 commit comments