I'm trying to pattern match on a list of pairs, where I'm trying to return a list from the list of pair, however I'm having trouble figuring out where to make the recursive call. Without the recursive call I have this:
let countriesInChart (cht: chart) = match cht with | [] -> [] | (x,y)::tt -> [x;y];;
But naturally this only applies to the first pair in the list and simply returns ["countryA"; "countryB"]
without the rest of the list.
With the recursive call this simply only returns an empty list:
let rec countriesInChart (cht: chart) = match cht with | [] -> [] | (x,y)::tt -> [x;y]::countriesInChart tt ;;
How would I make the recursive call such that all the pairs in the list would return as a list?