Ленивость в окамле
Aug. 13th, 2013 04:17 pmutop[0]> open Core.Std;; utop[1]> let a = lazy (printf "A\n"; 0);; val a : int lazy_t = <lazy> utop[2]> let b (a : int) = lazy (printf "B\n"; 0);; val b : int -> int lazy_t = <fun> utop[3]> Lazy.force Lazy.(a >>= b);; A B - : int = 0
Ну ё-моё...
no subject
Date: 2013-08-13 01:54 pm (UTC)a = do
print "A"
return 0
b x = do
print "B"
return 0
main = a >>= b
$ ./Proba01
"A"
"B"
no subject
Date: 2013-08-13 03:49 pm (UTC)a = trace "A" 0и далее аналогично.