functionjoinpure
pure character(len=joined_length(list,sep)) function join(list, sep) result(text)
The strings of list with sep between them.
Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
| list | type(string_t) | in | dimension(:) | the strings |
| sep | character(len=*) | in | the separator |
Result
| Name | Type | Attributes | Description |
|---|---|---|---|
| text | character(len=joined_length(list,sep)) | private |
Source
Show the code
pure function join(list, sep) result(text)
type(string_t), intent(in) :: list(:) !! the strings
character(len=*), intent(in) :: sep !! the separator
character(len=joined_length(list, sep)) :: text
integer :: k, n
n = 0
do k = 1, size(list)
if (k > 1) then
text(n + 1:n + len(sep)) = sep
n = n + len(sep)
end if
text(n + 1:n + len(list(k)%s)) = list(k)%s
n = n + len(list(k)%s)
end do
end function join