在我的地圖功能: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