|
[Date Index]
[Thread Index]
[Author Index]
Re: Implementing a array assignment for custom data structure
- To: mathgroup at smc.vnet.net
- Subject: [mg88892] Re: Implementing a array assignment for custom data structure
- From: Oliver Ruebenkoenig <ruebenko at uni-freiburg.de>
- Date: Tue, 20 May 2008 06:53:18 -0400 (EDT)
- References: <g0tqub$mj9$1@smc.vnet.net>
Salvatore,
I am not sure I understand entirely what you are looking for, but how
about
In[1]:= mkFun[a_] := fun[a]
In[2]:= b=mkFun[1]
Out[2]= fun[1]
In[3]:= b
Out[3]= fun[1]
In[4]:= b[[1]]=2
Out[4]= 2
In[5]:= b
Out[5]= fun[2]
Oliver
On Tue, 20 May 2008, 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.
>
> Any ideas?
>
>
Oliver Ruebenkoenig, <ruebenko AT uni-freiburg.de>
Prev by Date:
Re: an easy one?
Next by Date:
Re: RenderBadPicture error while running
Previous by thread:
Implementing a array assignment for custom data structure
Next by thread:
Re: Implementing a array assignment for custom data structure
|