Sunday, February 1, 2009

Ch4, Ex13

Execute Following and notice both are monolithic
X = {Reverse1 [a b c]}
Y = {Reverse2 [a b c]}
{Browse X}
{Browse Y}
%First execute till here only
% then execute this
{Browse X.1}
% and then this
{Browse Y.1}

%Notice that whole [c b a] is displayed as soon as
%you display X.1 or Y.1

There is no difference in the results produced. Both are monolithic, that is as soon as the first element of the reversed list is needed, reverse of whole input list is calculated.

Second version is not good in terms of execution efficiency because making Rev lazy doesn't change anything but incurs the overhead of threads due to lazyness implementation.

No comments:

Post a Comment