[back]

String Triangle

Implement the function

val string_tri : string -> string

so that string_tri s a string with the same characters but organized as a right triangle. If the last line has too few letters, pad it with '*'. You may assume that s consists of visible ASCII characters.

Examples

let _ = assert (string_tri "ABCDE" = "A\nBC\nDE*")
let _ = assert (string_tri "ABCDEFGH" = "A\nBC\nDEF\nGH**")
let _ = assert (string_tri "AAA" = "A\nAA")