Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(string), | intent(in) | :: | self | The string. |
The reversed string.
Return a reversed string.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
integer, | public | :: | length | Length of the string. |
|||
integer, | public | :: | c | Counter. |
elemental function reverse(self) result(reversed)
!---------------------------------------------------------------------------------------------------------------------------------
!< Return a reversed string.
!---------------------------------------------------------------------------------------------------------------------------------
class(string), intent(in) :: self !< The string.
type(string) :: reversed !< The reversed string.
integer :: length !< Length of the string.
integer :: c !< Counter.
!---------------------------------------------------------------------------------------------------------------------------------
!---------------------------------------------------------------------------------------------------------------------------------
if (allocated(self%raw)) then
reversed = self
length = len(self%raw)
do c=1, length
reversed%raw(c:c) = self%raw(length-c+1:length-c+1)
enddo
endif
return
!---------------------------------------------------------------------------------------------------------------------------------
endfunction reverse