Skip to content

Commit a733bc3

Browse files
committed
documented function slice, corrected documentation of to_title and to_sentence
1 parent 9d72c69 commit a733bc3

File tree

2 files changed

+63
-2
lines changed

2 files changed

+63
-2
lines changed

doc/specs/stdlib_string_type.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1254,7 +1254,7 @@ The result is a scalar `string_type` value.
12541254

12551255
```fortran
12561256
program demo_to_title
1257-
use stdlib_string_type, only: string_type, to_title
1257+
use stdlib_string_type
12581258
implicit none
12591259
type(string_type) :: string, titlecase_string
12601260
@@ -1302,7 +1302,7 @@ The result is a scalar `string_type` value.
13021302

13031303
```fortran
13041304
program demo_to_sentence
1305-
use stdlib_string_type, only: string_type, to_sentence
1305+
use stdlib_string_type
13061306
implicit none
13071307
type(string_type) :: string, sentencecase_string
13081308

doc/specs/stdlib_strings.md

+61
Original file line numberDiff line numberDiff line change
@@ -192,3 +192,64 @@ program demo
192192
print'(a)', ends_with("pattern", "pat") ! F
193193
end program demo
194194
```
195+
196+
197+
<!-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -->
198+
### `slice`
199+
200+
#### Description
201+
202+
Extracts the characters from the defined region of the input string.
203+
Argument `first` and `last` defines the region for the function `slice` to operate.
204+
Extraction starts from the index `first` and takes stride of length `stride`.
205+
Argument `stride` cannot take the value 0.
206+
207+
#### Syntax
208+
209+
`string = [[stdlib_strings(module):slice(interface)]] (string, first, last, stride)`
210+
211+
#### Status
212+
213+
Experimental
214+
215+
#### Class
216+
217+
Pure function.
218+
219+
#### Argument
220+
221+
- `string`: Character scalar or [[stdlib_string_type(module):string_type(type)]]
222+
This argument is intent(in).
223+
- `first`: integer
224+
This argument is intent(in) and optional.
225+
- `last`: integer
226+
This argument is intent(in) and optional.
227+
- `stride`: integer
228+
This argument is intent(in) and optional.
229+
230+
#### Result value
231+
232+
The result is of the same type as `string`.
233+
234+
#### Example
235+
236+
```fortran
237+
program demo_slice
238+
use stdlib_string_type
239+
use stdlib_strings, only : slice
240+
implicit none
241+
type(string_type) :: string
242+
character(len=10) :: char
243+
244+
string = "abcdefghij"
245+
! string <-- "abcdefghij"
246+
247+
char = "abcdefghij"
248+
! char <-- "abcdefghij"
249+
250+
print'(a)', slice("abcdefghij", 2, 6, 2) ! "bdf"
251+
print'(a)', slice(string, 2, 6, 2) ! "bdf"
252+
print'(a)', slice(char, 2, 6, 2) ! "bdf"
253+
254+
end program demo_slice
255+
```

0 commit comments

Comments
 (0)