forked from solstice/solstice
started writing lexer after making string lib
This commit is contained in:
23
string/docs/modify/lower.md
Normal file
23
string/docs/modify/lower.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# string_Lower
|
||||
Make a string lowercase.
|
||||
|
||||
## Arguments
|
||||
- str (string): the string to make lowercase.
|
||||
|
||||
## Returns
|
||||
lowerString (string): the string in lowercase.
|
||||
|
||||
## Raises
|
||||
- `AllocFail`: raised if Ground failed to allocate memory for the new string.
|
||||
|
||||
## Example
|
||||
### Ground
|
||||
```python
|
||||
call !string_Lower "my STRING" &lowerString
|
||||
println $lowerString # "my string"
|
||||
```
|
||||
|
||||
### Solstice
|
||||
```c
|
||||
puts string_Lower("my STRING") // "my string"
|
||||
```
|
||||
24
string/docs/modify/repeat.md
Normal file
24
string/docs/modify/repeat.md
Normal file
@@ -0,0 +1,24 @@
|
||||
# string_Repeat
|
||||
Repeat a string `times` times.
|
||||
|
||||
## Arguments
|
||||
- str (string): the string to repeat.
|
||||
- times (int): the number of times to repeat the string.
|
||||
|
||||
## Returns
|
||||
result (string): the string repeated the given number of times.
|
||||
|
||||
## Raises
|
||||
- `AllocFail`: raised if Ground fails to allocate memory for the new string.
|
||||
|
||||
## Example
|
||||
### Ground
|
||||
```python
|
||||
call !string_Repeat "hi " 5 &repeated
|
||||
println $repeated # "hi hi hi hi hi "
|
||||
```
|
||||
|
||||
### Solstice
|
||||
```c
|
||||
puts string_Repeat("hi ", 5) // "hi hi hi hi hi "
|
||||
```
|
||||
22
string/docs/modify/replace.md
Normal file
22
string/docs/modify/replace.md
Normal file
@@ -0,0 +1,22 @@
|
||||
# string_Replace
|
||||
Replace all occurences of `from` in `str` with `to`.
|
||||
|
||||
## Arguments
|
||||
- str (string): the string to run a find and replace on.
|
||||
- from (string): the substring you want to replace.
|
||||
- to (string): the thing to replace all occurences of `from` with.
|
||||
|
||||
## Returns
|
||||
result (string): the resulting string after the find and replace.
|
||||
|
||||
## Example
|
||||
### Ground
|
||||
```python
|
||||
call !string_Replace "abacabacacacabacacacabac" "c" "b" &result
|
||||
println $result # "abababababababababababab"
|
||||
```
|
||||
|
||||
### Solstice
|
||||
```c
|
||||
puts string_Replace("abacabacacacabacacacabac", "c", "b") // "abababababababababababab"
|
||||
```
|
||||
23
string/docs/modify/reverse.md
Normal file
23
string/docs/modify/reverse.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# string_Reverse
|
||||
Get the reversed version of a string.
|
||||
|
||||
## Arguments
|
||||
- str (string): the string to reverse.
|
||||
|
||||
## Returns
|
||||
result (string): the reversed string.
|
||||
|
||||
## Raises
|
||||
- `AllocFail`: raised if Ground failed to allocate memory for the new string.
|
||||
|
||||
## Example
|
||||
### Ground
|
||||
```python
|
||||
call !string_Reverse "Hello, World!" &reverse
|
||||
println $reverse # "!dlroW, olleH"
|
||||
```
|
||||
|
||||
### Solstice
|
||||
```c
|
||||
puts string_Reverse("Hello, World!") // "!dlroW, olleH"
|
||||
```
|
||||
27
string/docs/modify/substring.md
Normal file
27
string/docs/modify/substring.md
Normal file
@@ -0,0 +1,27 @@
|
||||
# string_Substring
|
||||
Get a substring of a string.
|
||||
|
||||
## Arguments
|
||||
- str (string): the string to get a substring of.
|
||||
- start (int): starting index of the substring.
|
||||
- end (int): ending index of the substring.
|
||||
|
||||
## Returns
|
||||
substring (string): the substring of the given string.
|
||||
|
||||
## Raises
|
||||
- `AllocFail`: raised if Ground failed to allocate memory for the new string.
|
||||
- `EndBeforeStart`: raised if the `end` index is less than the `start` index.
|
||||
- `OutOfBounds`: raised if either the `end` or `start` index is outside the bounds of the string.
|
||||
|
||||
## Example
|
||||
### Ground
|
||||
```python
|
||||
call !string_Substring "Hello, World!" 1 3 &sub
|
||||
println $sub # "ell"
|
||||
```
|
||||
|
||||
### Solstice
|
||||
```c
|
||||
puts string_Substring("Hello, World!", 1, 3) // "ell"
|
||||
```
|
||||
23
string/docs/modify/trim.md
Normal file
23
string/docs/modify/trim.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# string_Trim
|
||||
Trim whitespace from both sides of a string.
|
||||
|
||||
## Arguments
|
||||
- str (string): the string to trim.
|
||||
|
||||
## Returns
|
||||
trimmed (string): the string with its whitespace removed.
|
||||
|
||||
## Raises
|
||||
- `AllocFail`: raised if Ground failed to allocate memory for the new string.
|
||||
|
||||
## Example
|
||||
### Ground
|
||||
```python
|
||||
call !string_Trim " aaabbb " &trimmed
|
||||
println $trimmed # "aaabbb"
|
||||
```
|
||||
|
||||
### Solstice
|
||||
```c
|
||||
puts string_Trim(" aaabbb ") // "aaabbb"
|
||||
```
|
||||
23
string/docs/modify/trim_left.md
Normal file
23
string/docs/modify/trim_left.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# string_TrimLeft
|
||||
Trim whitespace from the left side of a string.
|
||||
|
||||
## Arguments
|
||||
- str (string): the string to trim.
|
||||
|
||||
## Returns
|
||||
trimmed (string): the string with the whitespace removed on the left side.
|
||||
|
||||
## Raises
|
||||
- `AllocFail`: raised if Ground failed to allocate memory for the new string.
|
||||
|
||||
## Example
|
||||
### Ground
|
||||
```python
|
||||
call !string_TrimLeft " aaabbb " &trimmed
|
||||
println $trimmed # "aaabbb "
|
||||
```
|
||||
|
||||
### Solstice
|
||||
```c
|
||||
puts string_TrimLeft(" aaabbb ") // "aaabbb "
|
||||
```
|
||||
23
string/docs/modify/trim_right.md
Normal file
23
string/docs/modify/trim_right.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# string_TrimRight
|
||||
Trim whitespace from the right side of a string.
|
||||
|
||||
## Arguments
|
||||
- str (string): the string to trim.
|
||||
|
||||
## Returns
|
||||
trimmed (string): the string with the whitespace removed on the right side.
|
||||
|
||||
## Raises
|
||||
- `AllocFail`: raised if Ground failed to allocate memory for the new string.
|
||||
|
||||
## Example
|
||||
### Ground
|
||||
```python
|
||||
call !string_TrimRight " aaabbb " &trimmed
|
||||
println $trimmed # " aaabbb"
|
||||
```
|
||||
|
||||
### Solstice
|
||||
```c
|
||||
puts string_TrimRight(" aaabbb ") // " aaabbb"
|
||||
```
|
||||
23
string/docs/modify/upper.md
Normal file
23
string/docs/modify/upper.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# string_Upper
|
||||
Make a string uppercase.
|
||||
|
||||
## Arguments
|
||||
- str (string): the string to make uppercase.
|
||||
|
||||
## Returns
|
||||
upperString (string): the string in uppercase.
|
||||
|
||||
## Raises
|
||||
- `AllocFail`: raised if Ground failed to allocate memory for the new string.
|
||||
|
||||
## Example
|
||||
### Ground
|
||||
```python
|
||||
call !string_Upper "MY string" &upperString
|
||||
println $upperString # "MY STRING"
|
||||
```
|
||||
|
||||
### Solstice
|
||||
```c
|
||||
puts string_Upper("MY string") // "MY STRING"
|
||||
```
|
||||
Reference in New Issue
Block a user