Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #10942
| From | Andrzej Kozlowski <akozlowski@gmail.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: Algorithm Analysis Course: Should I use Mathematica for projects? |
| Date | 2012-07-15 08:27 +0000 |
| Message-ID | <jttutb$grp$1@smc.vnet.net> (permalink) |
| References | (5 earlier) <20120714052828.774436867@smc.vnet.net> <FB3DBDDB-A4F4-42A9-8B6D-A880E2980CDF@mimuw.edu.pl> <5001B612.9030903@eecs.berkeley.edu> <660F39E7-95EF-4C28-9C9E-1253EB80AE1A@gmail.com> <5001DA47.6080502@eecs.berkeley.edu> |
| Organization | Time-Warner Telecom |
On 14 Jul 2012, at 22:44, Richard Fateman wrote:
>> B = Table[i, {i, 0, 1000}];
>> B[[5]] = j; Timing[Do[B[[50]]++, {i, 0, 100000}]]
>>
>> This sort of thing can certainly change the length of a list. A simple example:
>>
>> Clear[B]
>>
>> j /: {a___, j, b__} := {a, 1, 1, b}
>>
>> B = Table[i, {i, 0, 5}];
>> Length[B]
>> 6
>>
>> B[[5]] = j;
>> Length[B]
>> 7
>>
>> It would seem to me that this alone should force re-evaluation of the list.
> The activity which is being timed is B[[50]] or B[[50]]++
> neither of which changes the length of the list/ size of the array.
Yes, but this can also trigger a change in the length if the list contains a symbol with and UpValue. For example:
j /: {a___, j, 3, b__} := {a, 1, 1, 2, b}
B = Table[i, {i, 0, 5}];
B[[2]] = j;
B[[2]] = j;
Do[B[[3]]++, {3}]
B
{0,1,1,2,3,4,5}
The length of the list has changed. As long as the list contains a symbol that might have an UpValue any change of any index can change the length of the list. I still think that makes re-evaluation necessary.
Andrzej
Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Algorithm Analysis Course: Should I use Mathematica for projects? Brentt <brenttnewman@gmail.com> - 2012-07-11 22:25 +0000
Re: Algorithm Analysis Course: Should I use Mathematica for projects? Richard Fateman <fateman@cs.berkeley.edu> - 2012-07-12 09:00 +0000
Re: Algorithm Analysis Course: Should I use Mathematica for projects? Helen Read <readhpr@gmail.com> - 2012-07-13 06:54 +0000
Re: Algorithm Analysis Course: Should I use Mathematica for projects? Joseph Gwinn <joegwinn@comcast.net> - 2012-07-13 06:55 +0000
Re: Algorithm Analysis Course: Should I use Mathematica for projects? Andrzej Kozlowski <akozlowski@gmail.com> - 2012-07-13 06:53 +0000
Re: Algorithm Analysis Course: Should I use Mathematica for projects? Andrzej Kozlowski <akozlowski@gmail.com> - 2012-07-14 05:29 +0000
Re: Algorithm Analysis Course: Should I use Mathematica for projects? Richard Fateman <fateman@cs.berkeley.edu> - 2012-07-14 05:28 +0000
Re: Algorithm Analysis Course: Should I use Mathematica for projects? Richard Fateman <fateman@eecs.berkeley.edu> - 2012-07-14 05:29 +0000
Re: Algorithm Analysis Course: Should I use Mathematica for projects? Andrzej Kozlowski <akozlowski@gmail.com> - 2012-07-15 08:31 +0000
Re: Algorithm Analysis Course: Should I use Mathematica for projects? Andrzej Kozlowski <akozlowski@gmail.com> - 2012-07-15 08:33 +0000
Re: Algorithm Analysis Course: Should I use Mathematica for projects? Andrzej Kozlowski <akozlowski@gmail.com> - 2012-07-15 08:27 +0000
Re: Algorithm Analysis Course: Should I use Mathematica for projects? Andrzej Kozlowski <akozlowski@gmail.com> - 2012-07-15 08:25 +0000
Re: Algorithm Analysis Course: Should I use Mathematica for projects? Andrzej Kozlowski <akozlowski@gmail.com> - 2012-07-15 08:32 +0000
Re: Algorithm Analysis Course: Should I use Mathematica for projects? David Bailey <dave@removedbailey.co.uk> - 2012-07-14 05:30 +0000
Re: Algorithm Analysis Course: Should I use Mathematica for projects? roby <roby.nowak@gmail.com> - 2012-07-23 23:57 +0000
csiph-web