Singular https://www.singular.uni-kl.de/forum/ |
|
redefine and kill in for loops https://www.singular.uni-kl.de/forum/viewtopic.php?f=10&t=2295 |
Page 1 of 1 |
Author: | Jack [ Thu Oct 10, 2013 12:41 pm ] |
Post subject: | redefine and kill in for loops |
Consider a list l of rings or other objects. Code: ... def S; int pos; for (pos=1; pos<=size(l); pos++) { s=l[pos]; } Is it necessary to kill and redefine S in each loop step? |
Author: | hannes [ Fri Oct 11, 2013 11:38 am ] |
Post subject: | Re: redefine and kill in for loops |
If you want to assign l[pos] to s then the types must allow this. For example, if s is of type int and l[pos] is of type string, the assignment is not possible. But if s will destroyed first and redefined as of type def the assignment works and the type of s (which started as type def) changes to string. |
Page 1 of 1 | All times are UTC + 1 hour [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |