ocaml: phase 5.1 array literals [|...|] + lis.ml baseline (LIS = 6)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 35s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 35s
Added parser support for OCaml array literal syntax:
[| e1; e2; ...; en |] --> Array.of_list [e1; e2; ...; en]
[||] --> Array.of_list []
Desugaring keeps the array representation unchanged (ref-of-list)
since Array.of_list is a no-op constructor for that backing.
Tokenizer emits [, |, |, ] as separate ops; parser detects [ followed
by | and enters array-literal mode, terminating on |].
Baseline lis.ml exercises the syntax:
let lis arr =
let n = Array.length arr in
let dp = Array.make n 1 in
for i = 1 to n - 1 do
for j = 0 to i - 1 do
if arr.(j) < arr.(i) && dp.(j) + 1 > dp.(i) then
dp.(i) <- dp.(j) + 1
done
done;
let best = ref 0 in
for i = 0 to n - 1 do
if dp.(i) > !best then best := dp.(i)
done;
!best
lis [|10; 22; 9; 33; 21; 50; 41; 60; 80|] = 6
137 baseline programs total.
This commit is contained in:
@@ -68,6 +68,7 @@
|
||||
"fizz_classifier.ml": 540,
|
||||
"fizzbuzz.ml": 57,
|
||||
"flatten_tree.ml": 28,
|
||||
"lis.ml": 6,
|
||||
"list_ops.ml": 30,
|
||||
"luhn.ml": 2,
|
||||
"mat_mul.ml": 621,
|
||||
|
||||
Reference in New Issue
Block a user