LISP style question - (with-open-file)



I've read that a C programmer will write LISP as C. as i recall that
is attributed to Paul Graham. I seem to be in that category (except
I'm using Perl). I can't figure out what a proper style for LISP is
(or maybe there isn't and I'm just thinking that there is).

This involves the very common Perl task of munging data -- opening
files as input to read data, grabbing the data and manipulating it,
and opening files as output to write data. Here is a skeleton of some
typical Perl template that opens two files for input and opens tow
files for output:

my (%data_hash_in, %data_hash_out);
open IN1, '<', 'firstinput.txt';
while (<IN1>)
{
first_stuff_data_into_hash(); #using %data_hash_in
}
close IN1;

open IN2, '<', 'secondinput.txt';
while (<IN2>)
{
second_stuff_data_into_hash(); #using %data_hash_in
}
close IN2;

%data_hash_out = munge_data(%data_hash_in);

open OUT1, '>', 'csvoutput.csv';
open OUT2, '>', 'pdfoutput.pdf';
foreach my $key (sort keys %data_hash_out)
{
print_to_csv($data_hash_out{$key});
print_to_pdf($data_hash_out{$key});
}
close OUT1;
close OUT2;

exit(0);

The LISP template that I'm attempting to use looks something like
this:

(with-open-file
(open-and-read-file-1)
(with-open-file
(open-and-read-file-2)
(with-open-file
(open-and-print-to-file-3)
(with-open-file
(open-and-print-to-file-4)))))

My mental image of Perl is a sequential set of steps, called one after
another, processing lines iteratively. My mental image of LISP is an
outer function calling inner functions processing lines recursively.
Either this is an incorrect mental image of LISP or I'm not yet
equipped to write in proper LISP style (most likely).

What would be an appropriate style for the case of opening two files
(say, a students file and a classes file), mashing the data together
(with the students info and the classes info and the class), and
writing to two output files (say, a report cards file as a PDF and a
statistical analysis file in CSV)?

Thanks, CC.
.



Relevant Pages

  • Re: LISP style question - (with-open-file)
    ... I'm using Perl). ... typical Perl template that opens two files for input and opens tow ... The LISP template that I'm attempting to use looks something like ...
    (comp.lang.lisp)
  • Re: LISP style question - (with-open-file)
    ... I'm using Perl). ... typical Perl template that opens two files for input and opens tow ... The LISP template that I'm attempting to use looks something like ...
    (comp.lang.lisp)
  • Re: LISP style question - (with-open-file)
    ... The with-open-file macro can be considered a convenience macro for ... I'm using Perl). ... I can't figure out what a proper style for LISP is ... typical Perl template that opens two files for input and opens tow ...
    (comp.lang.lisp)
  • Re: async interrupts, without-aborts
    ... The Common Lisp standard does not address asynchronous ... asynchronous interrupts. ... This cannot happen in some implementations. ... You never know what might happen between the OS call that opens a file ...
    (comp.lang.lisp)
  • Re: How to make mod_lisp faster than php?
    ... then the modlisp.so code can reuse the socket ... I have to code much in PHP and only had a few days with modlisp. ... Lisp programming still running when the site was already delivered comes ... time when no page is requested opens a new pool on possibilities! ...
    (comp.lang.lisp)