tracks/ocaml/exercises/run-length-encoding/example.ml in trackler-2.2.1.110 vs tracks/ocaml/exercises/run-length-encoding/example.ml in trackler-2.2.1.111
- old
+ new
@@ -1,6 +1,6 @@
-open Core
+open Base
let (>|>) f g x = g (f x)
let repeat n ch =
Array.init n ~f:(fun _ -> ch)
@@ -8,11 +8,11 @@
|> String.of_char_list
let collapse = function
| [] -> failwith "empty string not expected here"
| [x] -> Char.to_string x
-| (x::_) as g -> sprintf "%d%c" (List.length g) x
+| (x::_) as g -> Printf.sprintf "%d%c" (List.length g) x
let to_int = String.of_char_list >|> Int.of_string
let decode_to_tuple (s: 'a list): ((int * 'a) * 'a list) =
match List.split_while ~f:Char.is_digit s with
@@ -20,10 +20,10 @@
| (ds, (x::xs)) -> let count = to_int ds in ((count, x), xs)
| _ -> failwith "case not expected"
let encode =
String.to_list
- >|> List.group ~break:((<>))
+ >|> List.group ~break:(Char.(<>))
>|> List.map ~f:collapse
>|> String.concat ~sep:""
let decode =
let rec go acc input =
\ No newline at end of file