'operands function works differently inside a procedure
Let's define a procedure
[> f:=proc(s)
s:={1}: {op(s),2};
end proc:
then
[> f('s');
{2, {1}}
but
[> s:={1}: {op(s),2};
{1, 2}
So why do we have a different result?
Using a local variable we can get the expected result though:
[> f:=proc(s) local S;
S:={1}: s:=S; {op(S),2};
end proc:
f('s');
{1, 2}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
