result:=[]
every ti:=!X.member_of do
put(result, something)I'm sure that you wrote something like that many times.
I would like that function put (result,something), if performed on unitialized variable, returns [something] so I can get rid of those result:=[] lines - there are plenty of such lines in each my program. Put doesn't do it. But, because Icon doesn't allow side effects (at least not that easily), I wasn't able to do much better. The best I succeeded to do it is
every ti:=!X.member_of do
result:=PUT(result, something)It doesn't require initialization result:=[] any more, but result still occur twice in this expression, and I didn't succeeded to reduce it on only one occurrence. Does anyone know how to do it, or at least that it is impossible? Preprocessor is allowed.
Or, if you want, it seems to me that problem is equivalent with: find expression that does
{/x:=[];x}
where x occur only once. Function calls and macros allowed.
----
Kazimir Majorinc, Zagreb, Croatia
