Skip to content

slice function's documentation made user friendly #456

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 11, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 13 additions & 17 deletions doc/specs/stdlib_strings.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,25 +199,21 @@ end program demo

#### Description

Extracts the characters from the defined region of the input string by taking strides.
Extracts the characters from the defined region of the input string by taking strides.
Argument `first` and `last` defines this region for extraction by function `slice`.
Argument `stride` defines the magnitude and direction (+/-) of stride to be taken while extraction.
`stride` when given invalid value 0, is converted to +1.

Deduction Process:
Deduction Process:
Function first automatically deduces the optional arguments that are not provided by the user.
This process is independent of both input `string` and permitted indexes of Fortran.
Deduced `first` and `last` argument take +infinity or -infinity value whereas deduced `stride` argument takes +1 or -1 value.

Validation Process:
Argument `first` and `last` defines this region for extraction by function `slice`.
If the defined region is invalid i.e. region contains atleast one invalid index, `first` and
`last` are converted to first and last valid indexes in this defined region respectively,
if no valid index exists in this region an empty string is returned.
`stride` can attain both negative or positive values but when the only invalid value
0 is given, it is converted to 1.

Extraction Process:
After all this, extraction starts from `first` index and takes stride of length `stride`.
Extraction starts only if `last` index is crossable from `first` index with stride `stride`
and remains active until `last` index is crossed.
Deduced `first` and `last` argument take +infinity or -infinity value and deduced `stride` argument
takes value +1 or -1 depending upon the actual argument(s) provided by the user.

Extraction Process:
Extraction starts only if `last` is crossable from `first` with stride of `stride`.
Extraction starts from the first valid index in the defined region to take stride of `stride`
and ends when the last valid index in the defined region is crossed.
If no valid index exists in the defined region, empty string is returned.

#### Syntax

Expand Down