Skip to content

How to work with character arrays

In MARPLE, a string is a character vector -- each element is a single character:

      greeting  'Hello, world!'
      greeting
13

You can index, reverse, and reshape character vectors just like numeric ones:

      greeting[1]
H
      greeting
!dlrow ,olleH

Character matrices

A table of strings is a character matrix. Rows are padded with spaces to equal length:

      names  3 5'AliceBob  Clara'

This creates a 3-by-5 matrix where each row is a 5-character name.

Case conversion

      $::str::upper 'hello'
HELLO
      $::str::lower 'HELLO'
hello

See also: Trim whitespace, Standard library -- strings