Skip to content

Commit 048b638

Browse files
committed
added the concept of +inf and -inf in documentation
1 parent d60dad3 commit 048b638

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

doc/specs/stdlib_strings.md

+17-10
Original file line numberDiff line numberDiff line change
@@ -199,18 +199,25 @@ end program demo
199199

200200
#### Description
201201

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-
If the defined region is invalid (user provides atleast one invalid index), `first` and
205-
`last` indexes are converted to first and last valid indexes in this defined region respectively,
202+
Extracts the characters from the defined region of the input string by taking strides.
203+
204+
Deduction Process:
205+
Function first automatically deduces the optional arguments that are not provided by the user.
206+
This process is independent of both input `string` and permitted indexes of Fortran.
207+
Deduced `first` and `last` argument take +infinity or -infinity value whereas deduced `stride` argument takes +1 or -1 value.
208+
209+
Validation Process:
210+
Argument `first` and `last` defines this region for extraction by function `slice`.
211+
If the defined region is invalid i.e. region contains atleast one invalid index, `first` and
212+
`last` are converted to first and last valid indexes in this defined region respectively,
206213
if no valid index exists in this region an empty string is returned.
214+
`stride` can attain both negative or positive values but when the only invalid value
215+
0 is given, it is converted to 1.
207216

208-
`stride` can attain both negative or positive values but when the invalid value
209-
0 is given, it is converted to 1.
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.
217+
Extraction Process:
218+
After all this, extraction starts from `first` index and takes stride of length `stride`.
219+
Extraction starts only if `last` index is crossable from `first` index with stride `stride`
220+
and remains active until `last` index is crossed.
214221

215222
#### Syntax
216223

src/tests/string/test_string_functions.f90

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ subroutine test_slice_string
103103
call check(slice(test_string, first=2, last=6, stride=-1) == "")
104104
call check(slice(test_string, first=20, last=10, stride=2) == "")
105105

106-
! Invalid
106+
! Atleast one argument is invalid
107107
call check(slice(test_string, first=20, last=30, stride=2) == "tvxz")
108108
call check(slice(test_string, first=-20, last=30, stride=2) == "acegikmoqsuwy")
109109
call check(slice(test_string, first=26, last=30, stride=1) == "z")

0 commit comments

Comments
 (0)