Liquid Haskell verifies that this code matches the spec:
{-@
leftpad
:: Char
-> i : String
-> n : { n : Int | len i <= n }
-> { o : String | len o == n }
@-}
leftpad :: Char -> String -> Int -> String
leftpad c i n = replicate (n - length i) c ++ i
That's the full code!
Quote Tweet
1. Leftpad. Takes a padding character, a string, and a total length, returns the string padded with that length with that character. If length is less than string, does nothing.
rise4fun.com/Dafny/nbNTl
Show this thread
5
20
97



