[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: COBOL compiler



On Fri, 2003-08-29 at 19:37, Colin Watson wrote:
> On Fri, Aug 29, 2003 at 05:46:01PM -0500, Ron Johnson wrote:
> > On Fri, 2003-08-29 at 16:28, Bijan Soleymani wrote:
> > > Well then you do it differently:
> > > open(INPUT,"records.txt");
> > > LOOP: while($record = <INPUT>)
> > > {
> > > if(!input_filter($record))
> > >   {
> > >     next LOOP;
> > >   }
> > >   else
> > >   {
> > >     #code to process record
> > >   }
> > > }
> > > close(INPUT);
> > > 
> > > Where input_filter() is the winnowing function you define.
> > 
> > That's good, but where's the sort function?  Also, what if each
> > record-to-be-sorted doesn't come directly from records.txt?  Maybe,
> > for each record read from records.txt, you must also query some
> > other file(s), or a database, or must do some other algorithmic
> > calculation.
> 
> RTFM: 'perldoc -f sort'. None of this is terribly hard in Perl at all; I
> don't see the point of making people write pseudocode to prove the
> point.

Maybe it's because I don't know enough about Perl, but that looks
like it's only for in-memory lists.

> > The COBOL SORT verb has 3 sections:
> > INPUT - Records (from whatever input) are RELEASEd to the SORT buffers.
> >         Any winnowing or transformations can happen here.
> > SORT - You can figure that part out.
> > OUTPUT - Records are RETURNed from the actual sort and can be pro-
> >          cessed (transformed, summarized, etc).
> 
> Sounds like the 'map sort map' idiom in Perl that's often used for
> complex cases. (It's also a common optimization to factor out expensive
> transformations in the sort comparator.)

After reading 'perldoc -f map', that also looks like it only works
on in-memory lists.

-- 
-----------------------------------------------------------------
Ron Johnson, Jr. ron.l.johnson@cox.net
Jefferson, LA USA

When Swedes start committing terrorism, I'll become suspicious 
of Scandanavians.



Reply to: