string

package
v0.0.0-...-cc6b36f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 11, 2025 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All(isGood func(char.Char) bool, str String) bool

Determine whether all characters pass the test.

func Any

func Any(isGood func(char.Char) bool, str String) bool

Determine whether any characters pass the test.

func Contains

func Contains(sub String, str String) bool

See if the second string contains the first one.

func EndsWith

func EndsWith(sub String, str String) bool

See if the second string ends with the first one.

func Foldl

func Foldl[B any](f func(char.Char, B) B, state B, str String) B

Reduce a string from the left.

func Foldr

func Foldr[B any](f func(char.Char, B) B, state B, str String) B

Reduce a string from the right.

func Indexes

func Indexes(sub String, str String) list.List[basics.Int]

Get all of the indexes for a substring in another string.

func Indices

func Indices(sub String, str String) list.List[basics.Int]

Alias for `indexes`.

func IsEmpty

func IsEmpty(x String) bool

Determine if a string is empty.

func Length

func Length(x String) basics.Int

Get the length of a string.

func Lines

func Lines(str String) list.List[String]

Break a string into lines, splitting on newlines.

func Split

func Split(sep String, s String) list.List[String]

Split a string using a given separator.

func StartsWith

func StartsWith(sub String, str String) bool

See if the second string starts with the first one.

func ToFloat

func ToFloat(x String) maybe.Maybe[basics.Float]

Try to convert a string into a float, failing on improperly formatted strings.

func ToInt

func ToInt(x String) maybe.Maybe[basics.Int]

Try to convert a string into an int, failing on improperly formatted strings.

func ToList

func ToList(str String) list.List[char.Char]

Convert a string to a list of characters.

func Uncons

func Uncons(str String) maybe.Maybe[tuple.Tuple2[char.Char, String]]

Split a non-empty string into its head and tail. This lets you pattern match on strings exactly as you would with lists.

func Words

func Words(str String) list.List[String]

Break a string into words, splitting on chunks of whitespace.

Types

type String

type String string

func Append

func Append(x String, y String) String

Append two strings. You can also use basics.Append to do this.

func Concat

func Concat(chunks list.List[String]) String

Concatenate many strings into one.

func Cons

func Cons(char char.Char, str String) String

Add a character to the beginning of a string.

func DropLeft

func DropLeft(n basics.Int, str String) String

Drop *n* characters from the left side of a string.

func DropRight

func DropRight(n basics.Int, str String) String

Drop *n* characters from the right side of a string.

func Filter

func Filter(isGood func(char.Char) bool, str String) String

Keep only the characters that pass the test.

func FromChar

func FromChar(char char.Char) String

Create a string from a given character.

func FromFloat

func FromFloat(x basics.Float) String

Convert a Float to a String.

func FromInt

func FromInt(x basics.Int) String

Convert an Int to a String.

func FromList

func FromList(chars list.List[char.Char]) String

Convert a list of characters into a String. Can be useful if you want to create a string primarily by consing, perhaps for decoding something.

func Join

func Join(sep String, chunks list.List[String]) String

Put many strings together with a given separator.

func Left

func Left(n basics.Int, str String) String

Take *n* characters from the left side of a string.

func Map

func Map(f func(char.Char) char.Char, str String) String

Transform every character in a string

func Pad

func Pad(n basics.Int, char char.Char, str String) String

Pad a string on both sides until it has a given length.

func PadLeft

func PadLeft(n basics.Int, char char.Char, str String) String

Pad a string on the left until it has a given length.

func PadRight

func PadRight(n basics.Int, char char.Char, str String) String

Pad a string on the right until it has a given length.

func Repeat

func Repeat(n basics.Int, chunk String) String

Repeat a string n times.

func Replace

func Replace(before String, after String, str String) String

Replace all occurrences of some substring.

func Reverse

func Reverse(x String) String

Reverse a string.

func Right(n basics.Int, str String) String

Take *n* characters from the right side of a string.

func Slice

func Slice(start basics.Int, end basics.Int, str String) String

Take a substring given a start and end index. Negative indexes are taken starting from the end of the list.

func ToLower

func ToLower(str String) String

Convert a string to all lower case. Useful for case-insensitive comparisons.

func ToUpper

func ToUpper(str String) String

Convert a string to all upper case. Useful for case-insensitive comparisons and VIRTUAL YELLING.

func Trim

func Trim(str String) String

Get rid of whitespace on both sides of a string.

func TrimLeft

func TrimLeft(str String) String

Get rid of whitespace on the left of a string.

func TrimRight

func TrimRight(str String) String

Get rid of whitespace on the right of a string.

func (String) App

func (String) Cmp

func (i String) Cmp(y basics.Comparable[String]) int

func (String) T

func (i String) T() String

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL