// 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..]
}

// builder returns a fresh string builder. Append pieces with build_add and
// materialize once with build_str — O(n) total instead of O(n^2) for a long
// chain of `+`. The same functions are available unqualified as sb_new,
// sb_add, sb_str (used internally by this module's builtin-backed helpers).
fn builder() {
	return sb_new()
}

fn build_add(sb, piece) {
	return sb_add(sb, piece)
}

fn build_str(sb) {
	return sb_str(sb)
}
