OCaml - How do I return list of lists from a list? -


I have the following problem from a list, I have 3 different 3 elements, 3 modules = 1 element and Mod 3 = 2 Elements 3 different lists and the list of these 3 lists must be returned. My question is very clear - how can I do this?

I do not have much else yet, but you are going there:

  different xs = give it help with xs i = match xs i. [] _ - & gt; [] | HD A - & gt; If a modern 3 = 0 / // a modern 3 = 1 other  

was updated: the finished code:

  different xs = Rick support (list, i , Xs1, xs2, xs3) = with match list. [] - & gt; [Xs1; Xs2; Xs3] | Head :: tail - & gt; (If I have 3 3 = 0 then help (tail, i + 1, head :: xs1, xs2, xs3) and if i 3 = 1 models then help (tail, i + 1, xs1, head :: xs2, xs3) Other help (tail, i + 1, xs1, xs2, head :: xs3)) help (xs, 0, [], [], []) ;;  

You must submit partial results to lists, and then return those lists Will be:

  let's split_by_mod_3 l = REC Aul L mod0 mod1 mod2 = with match L | [] - & gt; [Mod0; Mod1; Mod2] | | HD :: Tails when HD MD3 == 0 - & gt; Aux tail (hd :: mod0) mod1 mod2 | HD :: Tails when HD MD3 == 1 - & gt; Aux tail mod0 (hd :: mod1) mod2 | HD :: Tails when HD MD3 == 2 - & gt; Aux tail mod0 mod1 (hd :: mod2) in aux l [] [] [] ;;  

Comments