You should have a look at List.iter
, List.filter
, and List.map
. Moreover, rather than updating the global reference at each step, you should write a function that append together two lists and then uses this function to update the global reference. (and are you sure that you need such global state?). Finally, you should specify what you are trying to do and what is not working rather than what mechanism you are trying to use.