Pad s : String
with repeated occurrences of c : Char
until it's of length n
.
If s
is initially larger than n
, just return s
.
Equations
- String.leftpad n c s = { data := List.leftpad n c s.data }
Instances For
Construct the string consisting of n
copies of the character c
.
Equations
- String.replicate n c = { data := List.replicate n c }
Instances For
Pad s : String
with repeated occurrences of c : Char
on the right until it's of length n
.
If s
is initially larger than n
, just return s
.
Equations
- String.rightpad n c s = s ++ String.replicate (n - String.length s) c
Instances For
s.IsPrefix t
checks if the string s
is a prefix of the string t
.
Equations
- String.IsPrefix x✝ x = match x✝, x with | { data := d1 }, { data := d2 } => d1 <+: d2
Instances For
s.IsSuffix t
checks if the string s
is a suffix of the string t
.
Equations
- String.IsSuffix x✝ x = match x✝, x with | { data := d1 }, { data := d2 } => d1 <:+ d2
Instances For
String.mapTokens c f s
tokenizes s : string
on c : char
, maps f
over each token, and
then reassembles the string by intercalating the separator token c
over the mapped tokens.
Equations
- String.mapTokens c f = String.intercalate (String.singleton c) ∘ List.map f ∘ fun (x : String) => String.split x fun (x : Char) => decide (x = c)
Instances For
getRest s t
returns some r
if s = t ++ r
.
If t
is not a prefix of s
, it returns none
.
Equations
- String.getRest s t = List.asString <$> List.getRest (String.toList s) (String.toList t)
Instances For
Produce the head character from the string s
, if s
is not empty, otherwise 'A'
.