-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New zfill function to left-pad a string with zeros (#689)
* New zfill function to left-pad a string with zeros * Minor edit --------- Co-authored-by: ecasglez <[email protected]> Co-authored-by: Milan Curcic <[email protected]>
- Loading branch information
1 parent
4da9933
commit 8f7ac8d
Showing
5 changed files
with
140 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ ADD_EXAMPLE(slice) | |
ADD_EXAMPLE(starts_with) | ||
ADD_EXAMPLE(strip) | ||
ADD_EXAMPLE(to_string) | ||
ADD_EXAMPLE(zfill) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
program example_zfill | ||
use stdlib_string_type, only: string_type, assignment(=), write (formatted) | ||
use stdlib_strings, only: zfill | ||
implicit none | ||
type(string_type) :: string | ||
|
||
string = "left pad this string with zeros" | ||
! string <-- "left pad this string with zeros" | ||
|
||
print '(dt)', zfill(string, 36) ! "00000left pad this string with zeros" | ||
|
||
string = zfill(string, 36) | ||
! string <-- "00000left pad this string with zeros" | ||
|
||
end program example_zfill |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters