Quantcast
Channel: Active questions tagged ocaml - Stack Overflow
Viewing all articles
Browse latest Browse all 527

How to split a list in two list

$
0
0

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.


Viewing all articles
Browse latest Browse all 527

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>