From 8fabba0fd16a8017e262b3b3041bf7f1cd9ea8e5 Mon Sep 17 00:00:00 2001 From: Aman-Godara Date: Fri, 9 Jul 2021 17:58:01 +0530 Subject: [PATCH 1/2] made slice function's documentation beginner friendly --- doc/specs/stdlib_strings.md | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/doc/specs/stdlib_strings.md b/doc/specs/stdlib_strings.md index d5f22519c..31f752f11 100644 --- a/doc/specs/stdlib_strings.md +++ b/doc/specs/stdlib_strings.md @@ -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 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. +Extraction starts only if `last` is crossable from `first` with stride of `stride`. #### Syntax From ca82b5ec9d98058c0c11ce8b57dcdc737cffc44b Mon Sep 17 00:00:00 2001 From: Aman-Godara Date: Fri, 9 Jul 2021 18:12:39 +0530 Subject: [PATCH 2/2] changed row of line 216 to 213: to make doc error free --- doc/specs/stdlib_strings.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/specs/stdlib_strings.md b/doc/specs/stdlib_strings.md index 31f752f11..e0b2304af 100644 --- a/doc/specs/stdlib_strings.md +++ b/doc/specs/stdlib_strings.md @@ -210,10 +210,10 @@ Deduced `first` and `last` argument take +infinity or -infinity value and deduce 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. -Extraction starts only if `last` is crossable from `first` with stride of `stride`. #### Syntax