Home / Docs / Guides

Text

Release v0.4.0

Edition 0.2 adds functions that take a text apart, search it, change it and parse it (spec/22). Each is a prelude function called with method syntax.

una
module csv

--- The fields of a line, without the spaces around them.
pub fields(line: Text) -> List[Text]
=
  let comma = ","
  let parts = line.split(on: comma)
  parts.map(each: fn(part) -> part.trim())

--- The number at the start of a field, or 0.
pub leading_number(field: Text) -> Int
=
  let space = " "
  let end = field.find(text: space)
    if none use field.len
  let digits = field.slice(start: 0, end: end)
  let n = digits.parse_int()
    if error use 0
  n