我发现这种类型
zipper
和get
函数定义如下:
type 'a zipper = 'a list * int
Exception Empty
let empty = ([], 0)
(* get: returns the sublist starting at focus position *)
let rec get lz =
match lz with
| (l, 0) -> l
| (h::t, n) when n > 0 -> get (t, n-1)
| _ -> raise Empty
但是我不清楚
when n > 0
,那是没有必要的,因为assuming我们将提供参数n > 0
,它总是会被第一场比赛捕获,这不是正确的吗?为什么是when n > 0
?