I want to write a function that can return every other element of the list like this ['a' ; 'b' ; 'c' ; 'd' ; 'e'] can return: ['a' ; 'c' ; 'e']My function can use only with predefined functions List.hd, List.tl or List.length.I wrote this but I think something wrong...
remove_half l = let rec rm_half n l = if l = [] then [] else let fst = hd l in let rest = tl l in if n then fst :: (rm_half (not n) rest) else (rm_half (not n) rest) in rm_half true l;;