Re: Implementing a array assignment for custom data structure

• To: mathgroup at smc.vnet.net
• Subject: [mg88909] Re: Implementing a array assignment for custom data structure
• From: Salvatore Mangano <smangano at into-technology.com>
• Date: Wed, 21 May 2008 14:48:54 -0400 (EDT)

```Thanks, but that is not my problem. Think of my problem like this. Imagine Mathematica did not have SparseArray and someone wanted to implement it themselves. It is clear that you could get array access to work for your custom implementation using UpValues:

SparseArray /: Part[SparseArray[a___], index_Integer] := sparseGetFunction(a, index)

However it is not obvious how to get this to work for Set using either Up or Down values. If you try:

Set[Part[SparseArray[a___], index_Integer], value_] :=
sparseSetFunction(a, index,value)

It will not work with:

myArray = SparseArray[{{1} -> 10, {30} -> 15}]

myArray[] = 15

because Set (=) does not evaluate its first argument so Mathematica will not match the pattern and invoke sparseSetFunction.

```

• Prev by Date: Help with find root needed
• Next by Date: Plotting a series of piecewise functions
• Previous by thread: Re: Implementing a array assignment for custom data structure
• Next by thread: Re: Implementing a array assignment for custom data structure
{"ft_lang_label":"__label__en","ft_lang_prob":0.724766,"math_prob":0.604019,"size":1029,"snap":"2020-24-2020-29","text_gpt3_token_len":263,"char_repetition_ratio":0.114146344,"word_repetition_ratio":0.06622516,"special_character_ratio":0.26724976,"punctuation_ratio":0.1631579,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9504783,"pos_list":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14],"im_url_duplicate_count":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-05-29T14:26:31Z\",\"WARC-Record-ID\":\"<urn:uuid:43612e03-6f0f-4848-9b44-12f32f4131a2>\",\"Content-Length\":\"44357\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:573b40c6-291e-44a4-8655-8fc75546046f>\",\"WARC-Concurrent-To\":\"<urn:uuid:7064dc95-d865-482a-a3a1-74f731cbb718>\",\"WARC-IP-Address\":\"140.177.205.73\",\"WARC-Target-URI\":\"http://forums.wolfram.com/mathgroup/archive/2008/May/msg00610.html\",\"WARC-Payload-Digest\":\"sha1:TCNHHP3T3P2UJI46TF3PTOY5RN5PMWX3\",\"WARC-Block-Digest\":\"sha1:AHMLWPGWZBPEEJLBFQTVYBUJD5FI55SD\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-24/CC-MAIN-2020-24_segments_1590347404857.23_warc_CC-MAIN-20200529121120-20200529151120-00314.warc.gz\"}"}