File tree Expand file tree Collapse file tree 5 files changed +12
-12
lines changed
exercises/practice/word-count/.meta Expand file tree Collapse file tree 5 files changed +12
-12
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ type position =
11
11
| Start
12
12
| End
13
13
14
- let quote_at s ~pos =
14
+ let quote_at s ~pos =
15
15
let p = match pos with
16
16
| Start -> 0
17
17
| End -> String. length s - 1
@@ -20,12 +20,12 @@ let quote_at s ~pos =
20
20
21
21
let word_count s =
22
22
let s = String. map s ~f: normalize in
23
- let split =
23
+ let split =
24
24
List. filter (String. split s ~on: ' ' ) ~f: (Fn. non String. is_empty)
25
- |> List. map ~f: (fun w ->
25
+ |> List. map ~f: (fun w ->
26
26
let len = String. length w in
27
- if len > = 2 && quote_at w ~pos: Start && quote_at w ~pos: End
28
- then Caml. String. sub w 1 (len - 2 )
27
+ if len > = 2 && quote_at w ~pos: Start && quote_at w ~pos: End
28
+ then String. sub w ~pos: 1 ~len: (len - 2 )
29
29
else w)
30
30
in
31
31
List. fold ~init: (Map. empty (module String )) ~f: add_to_map split
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ let command =
7
7
let cwd =
8
8
flag_optional_with_default_doc " w" string Sexp. of_string
9
9
~aliases: [" --cwd" ]
10
- ~default: (Caml.Sys . getcwd () ) ~doc: " directory to assume as cwd"
10
+ ~default: (Core_unix . getcwd () ) ~doc: " directory to assume as cwd"
11
11
and templates_folder =
12
12
flag_optional_with_default_doc " t" string Sexp. of_string
13
13
~aliases: [" --templates" ]
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ let of_candidate ~(tpl: string) ~(out: string) (c: Exercise_candidate.t): t =
20
20
let to_string (e : t ): string =
21
21
let print_description = function
22
22
| None -> " None"
23
- | Some d -> Caml. Printf. sprintf " %s" d
23
+ | Some d -> Printf. sprintf " %s" d
24
24
in
25
25
Printf. sprintf " ExerciseCandidate { name = \" %s\" ; directory = \" %s\" ; description = \" %s\" ; canonical_data = %s; templates = %s }"
26
26
e.name
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ let mkdir_if_not_present dir =
31
31
32
32
let backup ~(base_folder : string ) ~(slug : string ) ~(contents : string ): bool =
33
33
mkdir_if_not_present base_folder;
34
- let path = Caml. Filename. concat base_folder slug in
34
+ let path = Filename. concat base_folder slug in
35
35
let matches_contents =
36
36
Option. try_with (fun () -> In_channel. read_all path)
37
37
|> Option. map ~f: (String. equal contents)
@@ -88,7 +88,7 @@ let read_file (p: string): (string, exn) Result.t =
88
88
try
89
89
let c = Stdio.In_channel. create p in
90
90
while true do
91
- Buffer. add_string b (Caml. input_line c);
91
+ Buffer. add_string b (In_channel. input_line_exn c);
92
92
Buffer. add_char b '\n' ;
93
93
done ;
94
94
failwith " unreachable"
Original file line number Diff line number Diff line change @@ -4,11 +4,11 @@ let split c s =
4
4
let len = String. length s in
5
5
let rec loop acc last_pos pos =
6
6
if pos = - 1 then
7
- Caml. String. sub s 0 last_pos :: acc
7
+ String. sub s ~pos: 0 ~len: last_pos :: acc
8
8
else
9
9
if Char. equal (String. get s pos) c then
10
10
let pos1 = pos + 1 in
11
- let sub_str = Caml. String. sub s pos1 (last_pos - pos1) in
11
+ let sub_str = String. sub s ~pos: pos1 ~len: (last_pos - pos1) in
12
12
loop (sub_str :: acc) pos (pos - 1 )
13
13
else loop acc last_pos (pos - 1 )
14
14
in
@@ -21,7 +21,7 @@ let find_substrings ?(start_point=0) substr x =
21
21
if len_x - i < len_s
22
22
then acc
23
23
else
24
- if String. equal (Caml. String. sub x i len_s) substr
24
+ if String. equal (String. sub x ~pos: i ~len: len_s) substr
25
25
then aux (i::acc) (i + 1 )
26
26
else aux acc (i + 1 )
27
27
in
You can’t perform that action at this time.
0 commit comments