forked from solstice/solstice
started writing lexer after making string lib
This commit is contained in:
21
string/docs/find/count.md
Normal file
21
string/docs/find/count.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# string_Count
|
||||
Count the number of times `needle` appears in `haystack`.
|
||||
|
||||
## Arguments
|
||||
- haystack (string): the string to search through.
|
||||
- needle (string): the substring to count.
|
||||
|
||||
## Returns
|
||||
count (int): the number of times `needle` appears in `haystack`.
|
||||
|
||||
## Example
|
||||
### Ground
|
||||
```python
|
||||
call !string_Count "Hello, World!" "l" &count
|
||||
println $count # 3
|
||||
```
|
||||
|
||||
### Solstice
|
||||
```c
|
||||
puts string_Count("Hello, World!", "l") // 3
|
||||
```
|
||||
21
string/docs/find/find.md
Normal file
21
string/docs/find/find.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# string_Find
|
||||
Look for the first occurence of `needle` in `haystack` and return its index in the string. If it isn't found, return -1.
|
||||
|
||||
## Arguments
|
||||
- haystack (string): the string to search.
|
||||
- needle (string): the substring to look for.
|
||||
|
||||
## Returns
|
||||
index (int): the index of the first occurence of `needle` in `haystack`. If it isn't found, return -1.
|
||||
|
||||
## Example
|
||||
### Ground
|
||||
```python
|
||||
call !string_Find "abcdefg" "d" &index
|
||||
println $index # 3
|
||||
```
|
||||
|
||||
### Solstice
|
||||
```c
|
||||
puts string_Find("abcdefg", "d") // 3
|
||||
```
|
||||
21
string/docs/find/find_last.md
Normal file
21
string/docs/find/find_last.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# string_FindLast
|
||||
Look for the last occurence of `needle` in `haystack` and return its index in the string. If it isn't found, return -1.
|
||||
|
||||
## Arguments
|
||||
- haystack (string): the string to search.
|
||||
- needle (string): the substring to look for.
|
||||
|
||||
## Returns
|
||||
index (int): the index of the last occurence of `needle` in `haystack`. If it isn't found, return -1.
|
||||
|
||||
## Example
|
||||
### Ground
|
||||
```python
|
||||
call !string_FindLast "abcabcabc" "b" &index
|
||||
println $index # 7
|
||||
```
|
||||
|
||||
### Solstice
|
||||
```c
|
||||
puts string_FindLast("abcabcabc", "b") // 7
|
||||
```
|
||||
Reference in New Issue
Block a user