Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: overloading "[" operator for newstructs
PostPosted: Wed Mar 19, 2014 5:35 pm 
Hello everyone, I am currently working on a package for handling arrangements of hyperplanes.

I already managed to get the operators "+" and "=" working to my confidence, but I am still struggling with "[".
So I want it to behave the same for our newstruct "arr" (which is basically a list) as it does for lists/ideals.

With
Code:
system("install", "arr" , "[", arrGet ,2);
I managed to get access, i.e. A[2]; returns me the second second hyperplane for an arrangement A.
However I cannot figure out to overload this for assignement, i.e. that A[2] = h; would actually save h as the second hyperplane of my arrangement.

So as far as I know in C one can do this like
Code:
public object this[int i]
{
    get { return InnerList[i]; }
    set { InnerList[i] = value; }
}


Is there a way to do this in Singular, too?


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

It is currently Fri May 13, 2022 10:58 am
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group