1. append() tip
- Posted by a.tammer at hetnet.nl May 30, 2002
- 529 views
Hi all, For the experienced users among you that didn't discover it yet: a=3Dappend(q, a) can easily be replaced by a&=3D{q} prepend(a,q) by a=3D{q}&{a} or variations of it. I hated to have to look up the function from the beginning, and came up with this. EUrs antoine tammer
2. Re: append() tip
- Posted by a.tammer at hetnet.nl May 30, 2002
- 510 views
sorry guys, might be the other way round, didn't consult refman when sending= it, didnt do it now either. find out for yourselves please. antoine
3. Re: append() tip
- Posted by a.tammer at hetnet.nl May 30, 2002
- 499 views
sorry guys, might be the other way round, didn't consult refman when sending= it, didnt do it now either. find out for yourselves please. antoine
4. Re: append() tip
- Posted by Sabal.Mike at notations.com May 30, 2002
- 509 views
I'm afraid that's not entirely correct. First of all, you are assuming that q is an atom, which is rarely the case when using append and concatenation. I must say that &= is an enigma to the language. While useful for concatenating two or three strings together, its use in building a sequence of data is inefficient. It is better to use repeat and a for loop for that purpose. Append or prepend are used in database tables when adding records to a sequence. I will not bore you with the details, as they are readily available in the archives and documentation, and will no doubt be discussed at great length again shortly. Michael J. Sabal >>> a.tammer at hetnet.nl 05/30/02 09:38AM >>> Hi all, For the experienced users among you that didn't discover it yet: a=append(q, a) can easily be replaced by a&={q} prepend(a,q) by a={q}&{a} or variations of it. I hated to have to look up the function from the beginning, and came up with this. EUrs antoine tammer
5. Re: append() tip
- Posted by a.tammer at hetnet.nl May 30, 2002
- 486 views
Sorry to disappoint you Mike, Try better, if q is an atom, an integer or a string IT WILL= function. I DO USE it on all these types in my ICD.lib I've the benefit of experience in this case. Antoine
6. Re: append() tip
- Posted by dm31 at uow.edu.au May 30, 2002
- 509 views
|a=append(q, a) can easily be replaced by | |a&={q} | |prepend(a,q) by | |a={q}&{a} <SNIP> Antoine, 2 small changes and it would be right a = append(a, q) -- change a &= {q} a = prepend(a, q) a = {q} & a -- change regards, Dan
7. Re: append() tip
- Posted by rforno at tutopia.com May 30, 2002
- 508 views
I find three issues to consider: 1) Both append(a, b) and prepend(a, b) need that 'a' be a sequence, not an atom. 2) At least for the cases presented in this message, both append() and prepend() are faster. 3) It is by no means clear why append() and prepend() should be more difficult to understand and apply than their counterparts, as it seems to be implied in this thread. I am not taking side for someone in this controversy, only stating what I think are facts. Regards. ----- Original Message ----- From: <dm31 at uow.edu.au> To: "EUforum" <EUforum at topica.com> Sent: Thursday, May 30, 2002 6:30 PM Subject: Re: append() tip |a=append(q, a) can easily be replaced by | |a&={q} | |prepend(a,q) by | |a={q}&{a} <SNIP> Antoine, 2 small changes and it would be right a = append(a, q) -- change a &= {q} a = prepend(a, q) a = {q} & a -- change regards, Dan
8. Re: append() tip
- Posted by dm31 at uow.edu.au May 31, 2002
- 506 views
|I find three issues to consider: |1) Both append(a, b) and prepend(a, b) need that 'a' be a sequence, not an |atom. |2) At least for the cases presented in this message, both append() and |prepend() are faster. |3) It is by no means clear why append() and prepend() should be more |difficult to understand and apply than their counterparts, as it seems to be |implied in this thread. |I am not taking side for someone in this controversy, only stating what I |think are facts. 1) Fair enough, but if you program correctly, it shouldn't be a problem. 2) I didn't test for these cases, but used a larger data set. Maybe they where optimised more in 2.3, because I did the times ages ago... 3)Speaking for myself only, I don't find it any harder to understand, I just thought it was faster... Guess I better check the times again in 2.3 Regards, Dan
9. Re: append() tip
- Posted by a.tammer at hetnet.nl May 31, 2002
- 482 views
Hi DM, Did state nowhere they were more difficult guy, just that 1) I had had to look up Refman for those. 2) Found my own way through using less keyhits Didnot state it was shorthand like +=3D &=3D etc. antoine
10. Re: append() tip
- Posted by Robert Craig <rds at RapidEuphoria.com> May 31, 2002
- 504 views
Chris Bensler writes: > x = append(x,y) <-- does eu type check x for a sequence in both instances? > > x &= y <-- only once? > > Besides preference, should there be any difference between the two forms? Appending an atom, y, onto the end of a sequence, x, can be done using: x = append(x, y) or: x &= y or: x = x & y The speed should be virtually identical in all three cases, as almost exactly the same code is executed internally. Not just similar code - the *same* code. Note that if y is not an atom, but rather a sequence, then append() and & are *not* interchangeable operations. Regarding timings: Don't leap to conclusions based on one short timing of some code. You should time something for several seconds at least, with all other apps shut down, and you should repeat the timing 3 times at least, to see if there is significant variation from one run to the next - there often is. Also, if you try version 1 of some code, followed by version 2, in the same program, it can sometimes make a difference which version you execute first, as the second version might be charged with the cost of deallocating all the storage used by the first version. Regards, Rob Craig Rapid Deployment Software http://www.RapidEuphoria.com