mirror of
https://github.com/bearlanguageorg/bear.git
synced 2026-08-27 17:57:01 +00:00
stdlin
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
// strings.vr — string helpers (part of the VuurRaaf stdlib).
|
||||
//
|
||||
// import strings
|
||||
// println(strings.join(["a", "b"], ", "))
|
||||
// println(strings.capitalize("hello"))
|
||||
|
||||
fn length(s) {
|
||||
return len(s)
|
||||
}
|
||||
|
||||
fn lines(s) {
|
||||
return split_lines(s)
|
||||
}
|
||||
|
||||
fn split(s, delim) {
|
||||
return split(s, delim)
|
||||
}
|
||||
|
||||
fn join(parts, delim) {
|
||||
return join(parts, delim)
|
||||
}
|
||||
|
||||
fn replace(s, from, to) {
|
||||
return replace(s, from, to)
|
||||
}
|
||||
|
||||
fn contains(s, sub) {
|
||||
return contains(s, sub)
|
||||
}
|
||||
|
||||
fn starts_with(s, prefix) {
|
||||
return starts_with(s, prefix)
|
||||
}
|
||||
|
||||
fn ends_with(s, suffix) {
|
||||
return ends_with(s, suffix)
|
||||
}
|
||||
|
||||
fn upper(s) {
|
||||
return upper(s)
|
||||
}
|
||||
|
||||
fn lower(s) {
|
||||
return lower(s)
|
||||
}
|
||||
|
||||
fn trim(s) {
|
||||
return trim(s)
|
||||
}
|
||||
|
||||
fn pad(s, width) {
|
||||
return pad(s, width)
|
||||
}
|
||||
|
||||
fn pad_left(s, width) {
|
||||
return pad_left(s, width)
|
||||
}
|
||||
|
||||
fn repeat(s, n) {
|
||||
return repeat(s, n)
|
||||
}
|
||||
|
||||
fn format(x, spec) {
|
||||
return format(x, spec)
|
||||
}
|
||||
|
||||
fn capitalize(s) {
|
||||
if len(s) == 0 {
|
||||
return s
|
||||
}
|
||||
return upper(s[0]) + s[1..]
|
||||
}
|
||||
Reference in New Issue
Block a user