tag:blogger.com,1999:blog-10416486.post6482517120858692581..comments2023-05-17T06:23:13.816-07:00Comments on Time: Lazy evaluation for tree replacement in Haskell, OCaml, and SMLShawnessyhttp://www.blogger.com/profile/16613856603034221042noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-10416486.post-71260201480934591442010-04-29T10:14:42.854-07:002010-04-29T10:14:42.854-07:00Hi Sean,
Your code actually traverses the tree tw...Hi Sean,<br /><br />Your code actually traverses the tree twice (once when lazy_from_fun p is forced, and once when you call p ()). To fix the OCaml version, you could say<br /><br /> let rec p = lazy (repmin t (fmap snd p)) in<br /> fst (Lazy.force p)<br /><br />I'm not sure how to fix the SML version, since this relies on OCaml's special support for lazy on the RHS of a let rec.<br /><br />I agree that a little bit of syntactic overhead (in OCaml) when you want laziness is well worth efficiency and predictability when you don't.Jake Donhamhttps://www.blogger.com/profile/04768087689799941690noreply@blogger.comtag:blogger.com,1999:blog-10416486.post-43382082054431958132010-04-28T18:13:52.496-07:002010-04-28T18:13:52.496-07:00Thank you!Thank you!Shawnessyhttps://www.blogger.com/profile/16613856603034221042noreply@blogger.comtag:blogger.com,1999:blog-10416486.post-57531219700378776362010-04-28T17:10:35.142-07:002010-04-28T17:10:35.142-07:00Here's another in MetaOCaml http://conway.rutg...Here's another in MetaOCaml http://conway.rutgers.edu/~ccshan/wiki/blog/posts/Circularity/Anonymousnoreply@blogger.com