Skip to content

Commit 24d417f

Browse files
committed
improved documentation and comments for function slice
1 parent 4598eec commit 24d417f

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

doc/specs/stdlib_strings.md

+4-5
Original file line numberDiff line numberDiff line change
@@ -205,13 +205,12 @@ If the defined region is invalid (user provides atleast one invalid index), `fir
205205
`last` indexes are converted to first and last valid indexes in this defined region respectively,
206206
if no valid index exists in this region an empty string is returned.
207207

208-
Extraction starts from `first` index and takes stride of length `stride`.
209-
Extraction is active until `last` index is crossed.
210-
Extraction starts only if `last` index is crossable from `first` index taking
211-
stride of length `stride`.
212208
`stride` can attain both negative or positive values but when the invalid value
213209
0 is given, it is converted to 1.
214-
Function automatically deduces the arguments which are not provided by the user.
210+
Extraction starts from `first` index and takes stride of length `stride`.
211+
Extraction starts only if `last` index is crossable from `first` index by taking
212+
stride of length `stride`and is active until `last` index is crossed.
213+
Function automatically deduces the optional arguments that are not provided by the user.
215214

216215
#### Syntax
217216

src/stdlib_strings.f90

+4-4
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ module stdlib_strings
5959
module procedure :: ends_with_char_char
6060
end interface ends_with
6161

62-
!> Slices the input string to return a new string
62+
!> Extracts characters from the input string to return a new string
6363
!>
6464
!> Version: experimental
6565
interface slice
@@ -299,9 +299,9 @@ elemental function ends_with_string_string(string, substring) result(match)
299299

300300
end function ends_with_string_string
301301

302-
!> Slices the region between the input 'first' and 'last' index (both inclusive)
302+
!> Extract the characters from the region between 'first' and 'last' index (both inclusive)
303303
!> of the input 'string' by taking strides of length 'stride'
304-
!> Returns a new string_type object
304+
!> Returns a new string
305305
elemental function slice_string(string, first, last, stride) result(sliced_string)
306306
type(string_type), intent(in) :: string
307307
integer, intent(in), optional :: first, last, stride
@@ -311,7 +311,7 @@ elemental function slice_string(string, first, last, stride) result(sliced_strin
311311

312312
end function slice_string
313313

314-
!> Slices the region between the input 'first' and 'last' index (both inclusive)
314+
!> Extract the characters from the region between 'first' and 'last' index (both inclusive)
315315
!> of the input 'string' by taking strides of length 'stride'
316316
!> Returns a new string
317317
pure function slice_char(string, first, last, stride) result(sliced_string)

0 commit comments

Comments
 (0)