Skip to content

Commit

Permalink
Use list init polyfill
Browse files Browse the repository at this point in the history
  • Loading branch information
jordwalke committed Jul 13, 2020
1 parent 104827f commit 04d7b53
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/reason-parser/reason_single_parser.ml
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,14 @@ let rec decompose_token pos0 split =
| Some(r) -> Some(List.rev gt_tokens @ r))
| _ -> None

let explode s = List.init (String.length s) (String.get s)

let rec init_tailrec_aux acc i n f =
if i >= n then acc
else init_tailrec_aux (f i :: acc) (i+1) n f

let list_init len f = List.rev (init_tailrec_aux [] 0 len f)

let explode s = list_init (String.length s) (String.get s)

let rec try_split_label (tok_kind, pos0, posn) =
match tok_kind with
Expand Down

0 comments on commit 04d7b53

Please sign in to comment.