Re: Problem with reading data from files?



Bil Kleb <Bil.Kleb@xxxxxxxx> wrote:

Richard Maine wrote:
<meek@xxxxxxxxxxxxxxx> wrote:
... or for all I know a dangling do is legal now ..?

Yes. Not only is it legal, it is perfect for this kind of application.
The OP has that exactly correct. Please don't lead him astray.

How would you allocate date and value, e.g.,

date(index) = a
value(index) = b

if you don't take the path of explicit dimensions?

Blocked reallocations?

There are all kinds of approaches to that. I don't have even close to
enough information to make a recommendation. (Though the fact that the
OP is new to the language suggests that it better be something pretty
simple, which likely rules out most of the options.) Blocked
reallocations is one option; I usually like the scheme of doubling the
size each time when I do that. Building a temporary linked list is
another. Not using an array at all is another. Or yes, using a fixed
size array and checking for hitting the limit is sometimes an option.
(And then there is the option of using a fixed size array, but not
bothering to check - an option that I see used far too often,
particularly when helping people dbug their code. :-(). I've done all of
the above at one time or other (though the times when I did the
unchecked fixed dimension were long ago, except in the most trivial of
throwaway code.)

But I don't see that as particularly correlated with the matter I was
addressing, which is the use of infinite DO loops. Yes, one can use a
finite DO loop as a form of limit checking of fixxed-size arrays. THat's
often handy in fact. But I didn't see any element of that in what I was
replying to. There was no suggestion that the DO loop go to size(date),
or anything comparable. All I saw was the "pick a large number" scheme,
which indeed I had been known to use myself in days gone by, but I would
never consider today. (I had stopped that practice and dropped back to
using loops built with goto sometime in my f77 days.)

--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain
.



Relevant Pages

  • Re: Global array operations: a performance hit?
    ... as if many DO loops were executed instead than just one. ... global array operations then? ... Note that the usual terminology is something more like "whole array ... once in a while they might also get you faster execution, ...
    (comp.lang.fortran)
  • Re: Puppy Mastiff wants to Nip at Faces
    ... first couple of weeks of an introductory data structures ... it seems to me by my recollection that loops were... ... in my first college textbook on structured programming. ... they did was loop through an array to show how you could easily access ...
    (rec.pets.dogs.behavior)
  • Re: Global array operations: a performance hit?
    ... when using array operations you have additional information ... which is not always the case in DO loops. ... optimizing array expressions. ... The compiler has to ...
    (comp.lang.fortran)
  • Re: Inefficient code?
    ... line is written to the output file. ... or read it into an array. ... # Backup File Field Positions ... Define 'my %found;' above the loops. ...
    (perl.beginners)
  • Re: Translating python to scheme
    ... Scheme has mutation, and there are reasons to use it. ... confusing when considering a 2d array. ... in other languages: Lisp Lists and Vectors. ...
    (comp.lang.scheme)