Add lowercase and uppercase string functions, update documentation accordingly.

This commit is contained in:
Sergey Chernov 2025-12-17 17:59:51 +01:00
parent 5d8fdce637
commit 1aef64e0fa
2 changed files with 41 additions and 25 deletions

View File

@ -1379,9 +1379,9 @@ Part match:
Typical set of String functions includes:
| fun/prop | description / notes |
|--------------------|------------------------------------------------------------|
| lower() | change case to unicode upper |
| upper() | change case to unicode lower |
|----------------------|------------------------------------------------------------|
| lower(), lowercase() | change case to unicode upper |
| upper(), uppercase() | change case to unicode lower |
| trim() | trim space chars from both ends |
| startsWith(prefix) | true if starts with a prefix |
| endsWith(prefix) | true if ends with a prefix |

View File

@ -216,6 +216,14 @@ data class ObjString(val value: String) : Obj() {
) {
thisAs<ObjString>().value.lowercase().let(::ObjString)
}
addFnDoc(
name = "lowercase",
doc = "Lowercase version of this string (default locale).",
returns = type("lyng.String"),
moduleName = "lyng.stdlib"
) {
thisAs<ObjString>().value.lowercase().let(::ObjString)
}
addFnDoc(
name = "upper",
doc = "Uppercase version of this string (default locale).",
@ -224,6 +232,14 @@ data class ObjString(val value: String) : Obj() {
) {
thisAs<ObjString>().value.uppercase().let(::ObjString)
}
addFnDoc(
name = "uppercase",
doc = "Uppercase version of this string (default locale).",
returns = type("lyng.String"),
moduleName = "lyng.stdlib"
) {
thisAs<ObjString>().value.uppercase().let(::ObjString)
}
addFnDoc(
name = "characters",
doc = "List of characters of this string.",