在我的地图功能:ocaml的 - Lazy.force
type 'a stream = Cons of 'a * 'a stream Lazy.t
let rec ones = Cons(1, lazy(ones));;
let rec map (f:'a -> 'b) (s:'a stream) : 'b stream =
match s with
|Cons(h,t) -> Cons(f h, lazy (map f (Lazy.force t)));;
;;
正确?懒惰。强行这样做已经使它记忆了?
'type'a t = unit - >'susp ref'的第二个间接的目的是什么?你只会返回'fun() - > r'或应用''let s = f()in'。你为什么不能削减中间人? PS:要清楚,我在问为什么http://ideone.com/Eidm34不起作用。 –
同意。这是没有必要的。我们应该输入''t ='susp ref'。间接性从以前的尝试中退化:) – seanmcl