To immediately answer your question: how do you take part of the list? Matching samples.
You can use pattern matching to write a function that extracts a range from a list. The main algorithm skips each element of the list, while E <Min, then take each element, and E <= Max. Something like that:
let range min max xs = let rec skipWhile f = function | x::xs when fx -> skipWhile f xs | xs -> xs let rec takeWhile f acc = function | x::xs when fx -> takeWhile f (x::acc) xs | _ -> List.rev acc xs |> skipWhile ((>) min) |> takeWhile ((>=) max) [] [1..12] |> range 4 9 > val it : int list = [4; 5; 6; 7; 8; 9]
source share