From svetosch@gmx.net Fri Jan 30 16:01:04 2009 From: Sven Schreiber To: gretl-devel@gretlml.univpm.it Subject: [Gretl-devel] Re: [Gretl-users] how to run multiple regressions at one time Date: Fri, 30 Jan 2009 22:01:02 +0100 Message-ID: <49836A8E.3050903@gmx.net> In-Reply-To: Pine.A41.4.58.0901292013080.315550@f1n11.sp2net.wfu.edu MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============6867914884603257495==" --===============6867914884603257495== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit [moving this over from users to devel] I guess what I mean is: in a 'loop for i=1..10' expression, the index i obviously takes on integer values, and it is clear that you have to do some type conversion to get strings out of that. Hence in that case $i is perfectly intuitive. However, in a 'loop foreach i peach pear plum' expression it... (a) either looks as if i takes on the names of the series. Then why on earth do I need to use $i instead of just plain i? Or... (b) the index i really must be thought as looking up the id numbers of the involved series, and hence is a number. But if series 'peach' has id#2, then I would expect $i to give the string representation of "2". In that case, to get back the name of 'peach' through the loop index i in the first iteration, I would rather have a syntax like 'name(i)', or some other prefix like '§i' or whatever. Otherwise IMHO it clashes with the use in the standard for loops, see above, and that's what I find confusing. Was that understandable know, or have I maybe got it all wrong? thanks for the patience, sven On 30.01.2009 02:22, Allin Cottrell wrote: > On Thu, 29 Jan 2009, Sven Schreiber wrote: >>> In a "foreach" loop the '$i' construction works by lookup: it >>> indexes into the relevant array of strings or variable names and >>> returns entry i at iteration i. >>> >>> In other sorts of loops, '$i' just gives the string representation >>> of the current index value, as if you had done >>> >>> sprintf foo "%d", i >> See I guess it's exactly this double, context-dependent, meaning >> that I find confusing. I associate $i with string >> representation, and then I'm all baffled why that (in a foreach >> loop context) won't give me a string with a series name, but >> some totally different thing. > > Er, sorry, but what totally different thing? "A string with a > series name" is exactly what it gives you, no? > > For example, in > > > > the loop part is equivalent to typing > > print price > print sqft > print bedrms > > and in > > > > the loop is equivalent to typing > > print "price" > print "sqft" > print "bedrms" > > I don't mean to be unhelpful, but I don't yet understand the > problem. It seems totally transparent to me ;-) (who wrote it!). > > Allin. > _______________________________________________ > Gretl-users mailing list > Gretl-users(a)lists.wfu.edu > http://lists.wfu.edu/mailman/listinfo/gretl-users > --===============6867914884603257495==--