1. 3.0.2 BUG! ( maybee)
- Posted by Hayden McKay <hmck1 at dodo.com.au> Mar 20, 2007
- 525 views
I don't know if this one has been posted before...
sequence a,b,c,d a = {} b = {} c = {} d = {} a &= {} b = append(b, {}) -- a = {} b = {{}} c &= 1 d = append(d, 1 ) -- c = {1} d = {1}
Whats wrong with 'a' ? ps. I have a long algorythm with lots of &=, append, [$] stuff that aint workin'. I'll have to trace it to find out more.
2. Re: 3.0.2 BUG! ( maybee)
- Posted by Chris Burch <chriscrylex at aol.com> Mar 20, 2007
- 517 views
Hayden McKay wrote: > > I don't know if this one has been posted before... > }}} <eucode> > sequence a,b,c,d > > a = {} b = {} c = {} d = {} > > a &= {} b = append(b, {}) -- a = {} b = {{}} > c &= 1 d = append(d, 1 ) -- c = {1} d = {1} > </eucode> {{{ > > Whats wrong with 'a' ? Nothing at all, this looks like normal behaviour. For &= read 'tack onto the end', and for append read append onto the end You define a as an empty sequence, which is fine. So a &= {} reads as 'tack an empty sequence onto an empty sequence' whereas b is defined as an empty sequence, but you then append another empty sequence to it - call it a place holder if you like, so that b is no longer empty, but contains another empty sequence. Make sense? Try this
sequence a, b, c, d a = {} b = {} c = {} d = {} a &= {} printf(1, "length(a) = %d\n", {length(a)} ) b = append(b, {}) printf(1, "length(b) = %d\n", {length(b)} ) c &= 1 --this is not empty printf(1, "length(c) = %d\n", {length(c)} ) d = append(d, 1) printf(1, "length(d) = %d\n", {length(d)} ) puts(1, 1/0)
> > ps. I have a long algorythm with lots of &=, append, [$] stuff that > aint workin'. I'll have to trace it to find out more. http://euallegro.wikispaces.com http://members.aol.com/chriscrylex/euphoria.htm http://uboard.proboards32.com/ http://members.aol.com/chriscrylex/EUSQLite/eusql.html
3. Re: 3.0.2 BUG! ( maybee)
- Posted by Hayden McKay <hmck1 at dodo.com.au> Mar 20, 2007
- 507 views
thanks for explanation. It's been a little while since i've cracked open euphoria. I wonder why I did'nt noticed that before? nb. I fixed my algo i had fdc -= j instead of fdc -= i stupid typo... lol. how many programmers does it take to change a light bulb? none it's a hardware problem!
4. Re: 3.0.2 BUG! ( maybee)
- Posted by Derek Parnell <ddparnell at bigpond.com> Mar 21, 2007
- 512 views
Hayden McKay wrote: > > I don't know if this one has been posted before... > }}} <eucode> > sequence a,b,c,d > > a = {} b = {} c = {} d = {} > > a &= {} b = append(b, {}) -- a = {} b = {{}} > c &= 1 d = append(d, 1 ) -- c = {1} d = {1} > </eucode> {{{ > > Whats wrong with 'a' ? This is how I remember the difference between &= and append() ... '&=' adds every element in the source to the target sequence. The length of the target sequence is increased by the length of the parameter. 'append()' adds the source as a single element to the target sequence. The length of the target sequence is increased by 1. Thus a &= {} gives every element of {} (i.e. none) is added to a. length(a) is increased by zero. b = append(b, {}) gives the source (an empty sequence) is added to b. length(b) is increased by 1. To get the same effect as append() when using '&=', wrap the source in '{}'. Thus a &= {{}} is the same as a = append(a, {}) -- Derek Parnell Melbourne, Australia Skype name: derek.j.parnell