let duplicates =
let rec duplicates' accumulator = function
| [] -> accumulator
| [ item ] -> duplicates' (item :: accumulator) []
| item :: item2 :: tail ->
if item = item2 then duplicates' (item :: accumulator) tail
else duplicates' (item::accumulator) (item2::tail)
in
duplicates' [];;
If I add a second parameter that must be a 'a list and use "match with" on it the code works.
(also: the end of codes and with: in duplicates [] 'parameter')
If I use function keyword and make the code more concise, the function returns:
val duplicates : '_weak14 list -> '_weak14 list = <fun>