Function in text coil-stdlib

join

fn join(Vec<string> parts, string sep) -> string
Import
use text::{join};
Source: src/text.hy

Returns the parts concatenated with sep between each pair.

Parameters#

NameType
partsVec<string>
sepstring

Returns#

string

Contracts#

Checked according to --contracts (see Contracts).

ensures parts.len() > 0 || result == ""
ensures parts.len() != 1 || result == parts[0]

Examples#

use text::{join};
use tests::assert;
let parts: Vec<string> = ["usr", "local", "bin"];
assert!(join(parts, "/") == "usr/local/bin");

See also#

  • byte_len: Returns the length of s in bytes; the same as s.len().
  • slice: Returns the part of s from byte offset start up to (not including) end.
  • trim_start: Returns s without leading ASCII whitespace (space, tab, CR, LF).
  • trim_end: Returns s without trailing ASCII whitespace (space, tab, CR, LF).
  • trim: Returns s without leading and trailing ASCII whitespace (space, tab, CR, LF).
  • rfind: Returns the byte offset of the last needle in hay, or -1.
  • split_at: Splits s at byte offset at into the part before and the part from at on.
  • repeat: Returns s repeated n times; empty when n <= 0.
↑ ↓ navigate ↵ open