Skip to content

Commit

Permalink
#234 Updated docs as func is moved from str tp seq.
Browse files Browse the repository at this point in the history
  • Loading branch information
ericzhang6222 committed May 13, 2020
1 parent 7d421e3 commit e53492a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ External libraries may be accessed via package references.
1. **`//math`:** math functions and constants such as `//math.sin`
and `//math.pi`.
2. **`//str`:** string functions such as `//str.upper` and
`//str.join`.
`//seq.join`.
3. **`//fn`:** higher order functions such as `//fn.fix` and `//fn.fixt`.
See the [standard library reference](std.md) for full documentation on all packages.
2. **`//{./path}`** provides access to other arrai files relative to the current
Expand Down
32 changes: 16 additions & 16 deletions docs/std-str.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

The `str` library contains functions that are used for string manipulations.

## `//str.contains(str <: string, substr <: string) <: bool`
## `//seq.contains(str <: string, substr <: string) <: bool`

`contains` checks whether `substr` is contained in `str`. It returns a
boolean.
Expand All @@ -11,21 +11,21 @@ Usage:

| example | equals |
|:-|:-|
| `//str.contains("the full string which has substring", "substring")` | `true` |
| `//str.contains("just some random sentence", "microwave")` | `{}` which is equal to `false` |
| `//seq.contains("the full string which has substring", "substring")` | `true` |
| `//seq.contains("just some random sentence", "microwave")` | `{}` which is equal to `false` |

## `//str.sub(s <: string, old <: string, new <: string) <: string`
## `//seq.sub(s <: string, old <: string, new <: string) <: string`

`sub` replaces occurrences of `old` in `s` with `new`. It returns the modified string.

Usage:

| example | equals |
|:-|:-|
| `//str.sub("this is the old string", "old string", "new sentence")` | `"this is the new sentence"` |
| `//str.sub("just another sentence", "string", "stuff")` | `"just another sentence"` |
| `//seq.sub("this is the old string", "old string", "new sentence")` | `"this is the new sentence"` |
| `//seq.sub("just another sentence", "string", "stuff")` | `"just another sentence"` |

## `//str.split(s <: string, delimiter <: string) <: array of string`
## `//seq.split(s <: string, delimiter <: string) <: array of string`

`split` splits the string `s` based on the provided `delimiter`. It returns an array of strings
which are split from the string `s`.
Expand All @@ -34,8 +34,8 @@ Usage:

| example | equals |
|:-|:-|
| `//str.split("deliberately adding spaces to demonstrate the split function", " ")` | `["deliberately", "adding", "spaces", "to", "demonstrate", "the", "split", "function"]` |
| `//str.split("this is just a random sentence", "random stuff")` | `["this is just a random sentence"]` |
| `//seq.split("deliberately adding spaces to demonstrate the split function", " ")` | `["deliberately", "adding", "spaces", "to", "demonstrate", "the", "split", "function"]` |
| `//seq.split("this is just a random sentence", "random stuff")` | `["this is just a random sentence"]` |

## `//str.lower(s <: string) <: string`

Expand Down Expand Up @@ -84,25 +84,25 @@ Usage:
| `//seq.has_prefix("I'm running out of stuff to write", "I'm")` | `true` |
| `//seq.has_prefix("I'm running out of stuff to write", "to write")` | `{}` which is equal to `false` |

## `//str.has_suffix(s <: string, suffix <: string) <: bool`
## `//seq.has_suffix(s <: string, suffix <: string) <: bool`

`has_suffix` checks whether the string `s` is suffixed by `suffix`. It returns a boolean.

Usage:

| example | equals |
|:-|:-|
| `//str.has_suffix("I'm running out of stuff to write", "I'm")` | `{}` which is equal to `false` |
| `//str.has_suffix("I'm running out of stuff to write", "to write")` | `true` |
| `//seq.has_suffix("I'm running out of stuff to write", "I'm")` | `{}` which is equal to `false` |
| `//seq.has_suffix("I'm running out of stuff to write", "to write")` | `true` |

## `//str.join(s <: array_of_string, delimiter <: string) <: string`
## `//seq.join(s <: array_of_string, delimiter <: string) <: string`

`join` returns a concatenated string with each member of `s` delimited by `delimiter`

Usage:

| example | equals |
|:-|:-|
| `//str.join(["pew", "another pew", "and more pews"], ", ")` | `"pew, another pew, and more pews"` |
| `//str.join(["this", "is", "a", "sentence"], " ")` | `"this is a sentence"` |
| `//str.join(["this", "is", "a", "sentence"], "")` | `"thisisasentence"` |
| `//seq.join(["pew", "another pew", "and more pews"], ", ")` | `"pew, another pew, and more pews"` |
| `//seq.join(["this", "is", "a", "sentence"], " ")` | `"this is a sentence"` |
| `//seq.join(["this", "is", "a", "sentence"], "")` | `"thisisasentence"` |

0 comments on commit e53492a

Please sign in to comment.