1. beginner question
- Posted by dmccu at connect.ab.ca Jan 23, 2002
- 358 views
Maybe I'm not understanding sequences as well as I think, but what happens if you don't know what the length of the sequence is at the start of the program and you want to keep adding to it? Do I have to initialize an extra long sequence of a large amount, in my case say 1000 elements to be sure? If so, how do I do that? Do I have to write out x{"","","","","", etc. 1000 times? I'm confused.
2. Re: beginner question
- Posted by Irv Mullins <irvm at ellijay.com> Jan 24, 2002
- 354 views
On Wednesday 23 January 2002 11:59 pm, you wrote: > > To "add to it," as you'd like to do, use append(): > mySeq = append(mySeq, anotherSeq) > > You can also use the following: > mySeq &= anotherSeq > > I think. I'm not so sure about that last one. append() and "&=" give very different results. Try this: include print.e sequence s1,s2 s1 = "Cat" s2 = "Cat" s1 = append(s1,"Dog") s2 &= "Dog" ? s1 ? s2 You'll see that the first instance - append - results in creating a new "subsequence' embedded within the first: {67,97,116, {68,111,103} } more or less "Cat{Dog}" while the second method -"&=" - results in a concatenating of the two strings : {67,97,116,68,111,103} or "CatDog". If you are wanting to create an "array" of strings: i.e. {"Cat","Dog"}, then s1 = append({s1},s2) does the job. Hint: download Gabriel Boehm's print.e include file from the Euphoria archives, it lets you see the contents of these things in plain English. Regards, Irv