implemented right

This commit is contained in:
Jonathan Lamothe
2019-09-02 09:40:57 -04:00
parent 60c662396f
commit 6145dd5c0c
2 changed files with 22 additions and 0 deletions
+10
View File
@@ -22,6 +22,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
module Mtlstats.Format
( padNum
, left
, right
) where
-- | Pad an 'Int' with leading zeroes to fit a certain character width
@@ -48,3 +49,12 @@ left
-- ^ The text to align
-> String
left n str = take n $ str ++ repeat ' '
-- | Aligns text to the right within a field (clipping if necessary)
right
:: Int
-- ^ The width of the field
-> String
-- ^ The text to align
-> String
right n str = reverse $ left n $ reverse str