Are pure functions cached
Subject: Are pure functions cached
Newsgroups: gmane.comp.lang.ocaml.beginners
Date: 2008-11-12 13:43:18 GMT
Hi
Is this sort of thing optimized in ocaml? I.e. the result of the
function cached implicitly? Assume that the function
'computationally_expensive_function' is pure (has no side-effects).
let computationally_expensive_function constant = (* something that
takes a while *)
computationally_expensive_function c
.
.
.
if computationally_expensive_function c then begin (* do something *) end
Whereas in C it's not true that the result is cached and you'd
probably rewrite the above as:
store = computationally_expensive_function(c);
.
.
.
if (store) { /* do something */ }
to prevent re-execution of the function.
Thanks
--
sashan
http://sashang.orcon.net.nz/
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch format to Traditional
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe
__,_._,___
RSS Feed