open System open System.Drawing open System.Threading type ScrollLetter = Letter of char | ColouredLetter of char * System.ConsoleColor let padStr (msg:string) = let screenWidth = Console.WindowWidth in match msg.Length > screenWidth with | true -> msg.Substring(0, screenWidth) | otherwise -> msg ^ String.make (screenWidth - msg.Length) ' ' let leftShiftMsg (msg:ScrollLetter list) = List.append msg.Tail [msg.Head] let colourSelector c = match c with | 'C' -> ConsoleColor.Magenta | 'M' -> ConsoleColor.Red | 'A' -> ConsoleColor.Yellow | otherwise -> ConsoleColor.Green let createMsg (str:string) = let charList = (padStr str).ToCharArray() |> Array.to_list in List.map (fun c -> match char.IsUpper c || char.IsPunctuation c with | true -> ColouredLetter (c, colourSelector c) | otherwise -> Letter c) charList let printMsg msg = List.iter (fun letter -> match letter with | Letter c -> Console.Write c | ColouredLetter (c,colour) -> let oldColour = ConsoleColor.White in Console.ForegroundColor <- colour; Console.Write (String.of_char c); Console.ForegroundColor <- oldColour ) msg let rec scroll msg = let newMsg = msg |> leftShiftMsg in Console.SetCursorPosition(0, 1); printMsg newMsg; Thread.Sleep(100); scroll newMsg let _ = createMsg "Congratulations Mark and Amber!!!" |> scroll