From db5a1b0c785001d95a51ad3397e2e51fbad49859 Mon Sep 17 00:00:00 2001 From: Tetralux Date: Mon, 21 Feb 2022 09:12:59 +0000 Subject: Add doc comments to strings.split() and strings.split_n() --- core/strings/strings.odin | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'core/strings/strings.odin') diff --git a/core/strings/strings.odin b/core/strings/strings.odin index 4daa0bacd..70a3ec8e8 100644 --- a/core/strings/strings.odin +++ b/core/strings/strings.odin @@ -280,10 +280,29 @@ _split :: proc(s_, sep: string, sep_save, n_: int, allocator := context.allocato return res[:i+1] } +/* + * Splits a string into parts, based on a separator. + * Returned strings are substrings of 's'. + * ``` + * s := "aaa.bbb.ccc.ddd.eee" // 5 parts + * ss := split(s, ".") + * fmt.println(ss) // [aaa, bbb, ccc, ddd, eee] + * ``` + */ split :: proc(s, sep: string, allocator := context.allocator) -> []string { return _split(s, sep, 0, -1, allocator) } +/* + * Splits a string into a total of 'n' parts, based on a separator. + * Returns fewer parts if there wasn't enough occurrences of the separator. + * Returned strings are substrings of 's'. + * ``` + * s := "aaa.bbb.ccc.ddd.eee" // 5 parts present + * ss := split_n(s, ".", 3) // total of 3 wanted + * fmt.println(ss) // [aaa, bbb, ccc.ddd.eee] + * ``` + */ split_n :: proc(s, sep: string, n: int, allocator := context.allocator) -> []string { return _split(s, sep, 0, n, allocator) } -- cgit v1.2.3 From 2abba6e0579d2e2451a2c922dc3341f0075625b1 Mon Sep 17 00:00:00 2001 From: Tetralux Date: Mon, 21 Feb 2022 09:51:03 +0000 Subject: Don't use leading asterisks --- core/strings/strings.odin | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'core/strings/strings.odin') diff --git a/core/strings/strings.odin b/core/strings/strings.odin index 70a3ec8e8..670da166b 100644 --- a/core/strings/strings.odin +++ b/core/strings/strings.odin @@ -281,28 +281,28 @@ _split :: proc(s_, sep: string, sep_save, n_: int, allocator := context.allocato } /* - * Splits a string into parts, based on a separator. - * Returned strings are substrings of 's'. - * ``` - * s := "aaa.bbb.ccc.ddd.eee" // 5 parts - * ss := split(s, ".") - * fmt.println(ss) // [aaa, bbb, ccc, ddd, eee] - * ``` - */ + Splits a string into parts, based on a separator. + Returned strings are substrings of 's'. + ``` + s := "aaa.bbb.ccc.ddd.eee" // 5 parts + ss := split(s, ".") + fmt.println(ss) // [aaa, bbb, ccc, ddd, eee] + ``` +*/ split :: proc(s, sep: string, allocator := context.allocator) -> []string { return _split(s, sep, 0, -1, allocator) } /* - * Splits a string into a total of 'n' parts, based on a separator. - * Returns fewer parts if there wasn't enough occurrences of the separator. - * Returned strings are substrings of 's'. - * ``` - * s := "aaa.bbb.ccc.ddd.eee" // 5 parts present - * ss := split_n(s, ".", 3) // total of 3 wanted - * fmt.println(ss) // [aaa, bbb, ccc.ddd.eee] - * ``` - */ + Splits a string into a total of 'n' parts, based on a separator. + Returns fewer parts if there wasn't enough occurrences of the separator. + Returned strings are substrings of 's'. + ``` + s := "aaa.bbb.ccc.ddd.eee" // 5 parts present + ss := split_n(s, ".", 3) // total of 3 wanted + fmt.println(ss) // [aaa, bbb, ccc.ddd.eee] + ``` +*/ split_n :: proc(s, sep: string, n: int, allocator := context.allocator) -> []string { return _split(s, sep, 0, n, allocator) } -- cgit v1.2.3