I have to make a function who splits a number list int two list:
[Int(17);Float(18.9);Int(777);Float(15.5)]
-> [Int(17);Int(777)] , [Float(18.9);Float(15.5)]
type number = | Int of int | Float of floatlet rec split_number_list: number list -> number list * number list = function lis -> match lis with |[] -> li,fi |(Int n)::l -> ((Int n)::li,fi) |(Float n)::l -> (li,(Float n)::fi)
I have two problems. First "Unbound value" appears for li
, then I tried to create two empty list called li
and fi
but that didn't worked. Second I don't know how to call split_number_list
in the function.