module Justify
where

-- Function written in class on 19 Sep 2014 to illustrate use of local
-- definitions for values like "lenstr" that are used in multiple
-- places.  This avoids recomputation and can make expressions
-- clearer.  Note use of lenstr within where clause itself.

rjustify :: Int -> String -> String
rjustify len str
    | lenstr <= len = pad ++ str
    | otherwise     = str -- ??? depends on context
    where
        lenstr = length str
        pad    = replicate (len-lenstr) ' '
