Dear all,
spoil1() and spoil3() functions are
somewhat more simple than spoil()
spoil2() and spoil4() differ from
spoil1() and spoil3() respectfully
by calling fun20() which does nothing!
<hansl
# creates list of all global series
function list fun1(void)
list retlist = seq(1,$nvars-1)
return retlist
end function
# identity list function
function list fun2(list a_list)
return a_list
end function
function void fun20(list a_list)
print ""
end function
# checking function
function void fu(string name)
catch eval @name
err = $error
if err
printf "Variable %s is not defined\n", name
endif
end function
function void fun4(void)
matrix x1 = 1
eval sin(x1)
end function
#(non)contaminating functions
function void spoil(void)
list list1 = fun1()
list list2 = fun2(list1)
end function
function void spoil1(void)
list list1 = fun1()
fun20(list1)
end function
function void spoil2(void)
list list1 = fun1()
end function
function void spoil3(void)
list a_list = seq(1,$nvars-1)
fun20(a_list)
end function
function void spoil4(void)
list a_list = seq(1,$nvars-1)
end function
###### examples
# contamination
nulldata 20
set seed 13
x1 = normal()
# before
fu("x1")
# looking at x1
print x1
# spoiling
spoil()
# after
fu("x1")
fun4()
nulldata 20
set seed 13
x1 = normal()
# before
fu("x1")
# looking at x1
print x1
# spoiling
spoil1()
# after
fu("x1")
# non-contamination
nulldata 20
set seed 13
x1 = normal()
# before
fu("x1")
# looking at x1
print x1
# spoiling
spoil2()
# after
fu("x1")
/*
function void fun20(list a_list)
print ""
end function
function void spoil1(void)
list list1 = fun1()
fun20(list1)
end function
function void spoil2(void)
list list1 = fun1()
end function
*/
# So spoil1() causes contamination,
# but spoil2() does not!
# the only difference betwwen them
# is
# calling fun20(list1) but
# fun20() actually does nothing!
# contamination
nulldata 20
set seed 13
x1 = normal()
# before
fu("x1")
# looking at x1
print x1
# spoiling
spoil3()
# after
fu("x1")
# non-contamination
nulldata 20
set seed 13
x1 = normal()
# before
fu("x1")
# looking at x1
print x1
# spoiling
spoil4()
# after
fu("x1")
/*
function void fun20(list a_list)
print ""
end function
function void spoil3(void)
list a_list = seq(1,$nvars-1)
fun20(a_list)
end function
function void spoil4(void)
list a_list = seq(1,$nvars-1)
end function
*/
# So spoil3() causes contamination,
# but spoil4() does not!
# Again, the only difference betwwen them
# is
# calling fun20(list1) but
# fun20() actually does nothing!
hansl>
Oleh