Question: I need help creating a make_assoc function in Ocaml. Shown below is the parameters and examples of what the final product should be: The function
I need help creating a "make_assoc" function in Ocaml. Shown below is the parameters and examples of what the final product should be:
The function make_assoc : string list list -> (int*int*string) list should translate a list of lists of strings into associative form: the list [[s11;...;s1k]; [s21;...;s2m];...[sN1;....;sNl]] should be translated to [(1,1,s11);...;(1,k,s1k);(2,1,s21);...;(2,m,s2m);...;(N,1,sN1)...;(N,l,sNl)]. Some concrete evaluations:
make_assoc [] and make_assoc [[]] should both evaluate to []
make_assoc [["a"]] should evaluate to [(1,1,"a")]
make_assoc [["a";"b"];["c"]] should evaluate to (a permutation of) [(2,1,"c"); (1,2,"b"); (1,1,"a")]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
