You are viewing a single comment's thread. Return to all comments →
Not too pretty – recursive pattern matching in F#
System.Console.ReadLine() |> List.ofSeq |> fun xs -> let rec take acc p count = function | [] -> match count with | 1 -> acc + (string p) | n -> acc + (string p) + (string count) | x::xs when x = p -> take acc x (count+1) xs | x::xs -> match count with | 1 -> take (acc + (string p)) x 1 xs | n -> take (acc + (string p) + (string n)) x 1 xs take "" xs.Head 1 xs.Tail |> printfn "%s"
Seems like cookies are disabled on this browser, please enable them to open this website
String Compression
You are viewing a single comment's thread. Return to all comments →
Not too pretty – recursive pattern matching in F#