MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Implementing a array assignment for custom data structure

  • To: mathgroup at smc.vnet.net
  • Subject: [mg88924] Re: Implementing a array assignment for custom data structure
  • From: Bill Rowe <readnews at sbcglobal.net>
  • Date: Wed, 21 May 2008 14:51:43 -0400 (EDT)

On 5/20/08 at 2:25 AM, smangano at into-technology.com (Salvatore
Mangano) wrote:

>Lists support a convenient syntax for element assignment:

>a[[i]]=v

>Of course this syntax is syntactic sugar for:

>Set[Part[a, i], v]

>SparseArray's have a different structure than lists but still
>support the same syntax.

>This leads me to believe that I should be able to implement a custom
>type (akin to SparseArray) that also allows this syntax (possibly
>using UpValues) but for the life of me I can't see how to accomplish
>this.

It would be helpful if you provided a specific example of what
you want to accomplish. But having said that, I don't know that
the existing syntax won't work for you. Pretty much any thing in
Mathematica can be viewed as having parts. For example:

In[32]:= f = x + y + z;
f[[2]] = 3;
f

Out[34]= x+z+3

The only real difficulty with more complex expressions is
identifying the part level specification needed to change the
portion of the expression you want changed.


  • Prev by Date: Re: How to connect one object to the other?
  • Next by Date: intersecting a hypercube and a hyperplane
  • Previous by thread: Re: Implementing a array assignment for custom data structure
  • Next by thread: Re: Implementing a array assignment for custom data structure