Increment and AddTo
- To: mathgroup at smc.vnet.net
- Subject: [mg64551] Increment and AddTo
- From: dh <dh at metrohm.ch>
- Date: Wed, 22 Feb 2006 05:58:34 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
Hello, can anybody explain the following behaviour: $Version = 5.1 for Microsoft Windows (October 25, 2004) i = 0; v = {1, 2, 3}; v[[++i]] += 10; v i gives {1,11,3} 2 i has been incremented by 2! i++ is even more interesting: i = 1; v = {1, 2, 3}; v[[i++]] += 10; v i gives: {1,11,3} 2 again i is incremented by 2, but for the sum v[[1]] is used and stored in v[[2]] Further: i = 0; v = {1, 2, 3}; ++v[[++i]] ; v i gives: {1,2,3} 2 Again i has been incremented by 2, but v has not been touched at all. Daniel
- Follow-Ups:
- Re: Increment and AddTo
- From: Sseziwa Mukasa <mukasa@jeol.com>
- Re: Increment and AddTo