Look-and-say sequence: Difference between revisions

Content added Content deleted
Line 691: Line 691:
let lookandsay =
let lookandsay =
Str.global_substitute (Str.regexp "\\(.\\)\\1*")
Str.global_substitute (Str.regexp "\\(.\\)\\1*")
(fun s -> let m = Str.matched_string s in
(fun s -> string_of_int (String.length (Str.matched_string s)) ^
string_of_int (String.length m) ^
Str.matched_group 1 s)
String.sub m 0 1)


let () =
let () =