如果让我在没有任何其他背景的情况下提高函数定义的效率let f h acc = (h :: List.hd acc) :: List.tl acc,我会说它已经足够高效了。
不过,我更喜欢使用模式匹配而不是List.hdand List.tl。它更安全(你自然会发现这种情况acc = []必须特殊处理),并且比两个函数调用稍微快一点:
let f h = function
| [] -> invalid_arg "empty list"
| xs::xss -> (h::xs) :: xss