From: gavino
Subject: script solution in common lisp
Date: 
Message-ID: <1184479108.319686.258530@m37g2000prh.googlegroups.com>
I have a file named movie1.
name1,500
name2,yellow

I want to write a program/script that  reads the value from the file
next to a name, with 1 comma in between.
For a number it will test if x > 400.
For the string it will test if sting = green
If the test fails, the result should be a file named movie.error with
the name,value pairs that FAIL in the test.
The real solution involves 25 different name,value pairs to be tested
as a subset of a 90 line name,value pair file; generated from 4,000
movies.
I am interested in how someone would do this in lisp.
I heard that high level languages also can do scripting as well.

From: Jeff Shrager
Subject: Re: script solution in common lisp
Date: 
Message-ID: <1184480403.661921.134680@g37g2000prf.googlegroups.com>
> I heard that high level languages also can do scripting as well.

Unfortunately, what you heard is incorrect. This problem cannot be
solved in Lisp. Probably some Lisp promoter was just saying that this
sort of thing could be accomplished in Lisp just to show off. But a
mere moment's thought will make it clear that, in fact, this problem
cannot be solved in finite time in any first order language on a von
neumann architecture, at least under classical newtonian assumptions
(which, of course, apply in any realistic case -- that is, unless you
are planning on building a quantum computer, flying your processor at
near light speeds, or running it in the vicinity of a very large
gravity well like the center of the galaxy).

I suggest using PERL.
From: Pascal Bourguignon
Subject: Re: script solution in common lisp
Date: 
Message-ID: <87y7hioyau.fsf@thalassa.lan.informatimago.com>
gavino <·········@gmail.com> writes:

> I have a file named movie1.
> name1,500
> name2,yellow
>
> I want to write a program/script that  reads the value from the file
> next to a name, with 1 comma in between.

You still cannot write it yourself???
Have you been reading:

    Common Lisp: A Gentle Introduction to Symbolic Computation
    David S. Touretzky
    http://www-cgi.cs.cmu.edu/afs/cs.cmu.edu/user/dst/www/LispBook/index.html
    http://www.cs.cmu.edu/~dst/LispBook/
?

What chapter did you reach?  Did you do the exercises?


> For a number it will test if x > 400.
> For the string it will test if sting = green
> If the test fails, the result should be a file named movie.error with
> the name,value pairs that FAIL in the test.

So far so good.


> The real solution involves 25 different name,value pairs to be tested
> as a subset of a 90 line name,value pair file; generated from 4,000
> movies.

I don't understand this "requirement".  Can you explain?


> I am interested in how someone would do this in lisp.



[···@thalassa tmp]$ ls -l movie.*
-rw-r--r-- 1 pjb pjb  70 Jul 15 10:32 movie.data
-rwxr-xr-x 1 pjb pjb 835 Jul 15 10:35 movie.script*
[···@thalassa tmp]$ cat movie.script 
#!/usr/bin/clisp -q -ansi -Kfull -E utf-8
;; -*- mode:lisp;coding:utf-8 -*-
(with-open-file (movie.error "movie.error" :direction :output
                  :if-exists :append
                  :if-does-not-exist :create)
 (loop
  :for line = (read-line *standard-input* nil nil)
  :while line 
  :do (let ((comma (position #\, line)))
        (when comma
           (let* ((name   (subseq line 0 comma))
                  (vfield (subseq line (1+ comma)))
                  (value  (or (ignore-errors (parse-integer vfield
                                                            :junk-allowed nil))
                              vfield)))
             (unless (if (integerp value)
                       (> value 400)
                       (string= value "green"))
                 (format movie.error "~A,~A~%" name value)))))))
[···@thalassa tmp]$ cat movie.data 
name1,500
name2,yellow
name3,300
name4,green
name5, green
name6, 500

[···@thalassa tmp]$ ./movie.script <movie.data 
[···@thalassa tmp]$ cat movie.error 
name2,yellow
name3,300
name5, green
[···@thalassa tmp]$ 



> I heard that high level languages also can do scripting as well.

Scripts are programs, and high level programming languages are better
than low level programming languages at creating programs, so no, high
level programming languages cannot do scripting as well, they can to
it better! :-)


My point here is that given the right abstractions, it can be as
simple to write a "script" in C or Lisp than it is to write it in
shell or perl.  What is bad in these script language is their syntaxes
and idiosyncraties.   What is good is the abstractions and "API" they
offer (eg to manage jobs).  If they were implemented as a library for
a high level programming language it would be perfect, but since
they're designed as languages by people who cannot and should be
forbidden to design languages, they're awful.

A very bad example is perl.  A good example is scsh.


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

NOTE: The most fundamental particles in this product are held
together by a "gluing" force about which little is currently known
and whose adhesive power can therefore not be permanently
guaranteed.
From: gavino
Subject: Re: script solution in common lisp
Date: 
Message-ID: <1184497074.652788.123050@i38g2000prf.googlegroups.com>
On Jul 15, 1:39 am, Pascal Bourguignon <····@informatimago.com> wrote:
> gavino <·········@gmail.com> writes:
> > I have a file named movie1.
> > name1,500
> > name2,yellow
>
> > I want to write a program/script that  reads the value from the file
> > next to a name, with 1 comma in between.
>
> You still cannot write it yourself???
> Have you been reading:
>
>     Common Lisp: A Gentle Introduction to Symbolic Computation
>     David S. Touretzky
>    http://www-cgi.cs.cmu.edu/afs/cs.cmu.edu/user/dst/www/LispBook/index....
>    http://www.cs.cmu.edu/~dst/LispBook/
> ?
>
> What chapter did you reach?  Did you do the exercises?
>
> > For a number it will test if x > 400.
> > For the string it will test if sting = green
> > If the test fails, the result should be a file named movie.error with
> > the name,value pairs that FAIL in the test.
>
> So far so good.
>
> > The real solution involves 25 different name,value pairs to be tested
> > as a subset of a 90 line name,value pair file; generated from 4,000
> > movies.
>
> I don't understand this "requirement".  Can you explain?
>
> > I am interested in how someone would do this in lisp.
>
> [···@thalassa tmp]$ ls -l movie.*
> -rw-r--r-- 1 pjb pjb  70 Jul 15 10:32 movie.data
> -rwxr-xr-x 1 pjb pjb 835 Jul 15 10:35 movie.script*
> [···@thalassa tmp]$ cat movie.script
> #!/usr/bin/clisp -q -ansi -Kfull -E utf-8
> ;; -*- mode:lisp;coding:utf-8 -*-
> (with-open-file (movie.error "movie.error" :direction :output
>                   :if-exists :append
>                   :if-does-not-exist :create)
>  (loop
>   :for line = (read-line *standard-input* nil nil)
>   :while line
>   :do (let ((comma (position #\, line)))
>         (when comma
>            (let* ((name   (subseq line 0 comma))
>                   (vfield (subseq line (1+ comma)))
>                   (value  (or (ignore-errors (parse-integer vfield
>                                                             :junk-allowed nil))
>                               vfield)))
>              (unless (if (integerp value)
>                        (> value 400)
>                        (string= value "green"))
>                  (format movie.error "~A,~A~%" name value)))))))
> [···@thalassa tmp]$ cat movie.data
> name1,500
> name2,yellow
> name3,300
> name4,green
> name5, green
> name6, 500
>
> [···@thalassa tmp]$ ./movie.script <movie.data
> [···@thalassa tmp]$ cat movie.error
> name2,yellow
> name3,300
> name5, green
> [···@thalassa tmp]$
>
> > I heard that high level languages also can do scripting as well.
>
> Scripts are programs, and high level programming languages are better
> than low level programming languages at creating programs, so no, high
> level programming languages cannot do scripting as well, they can to
> it better! :-)
>
> My point here is that given the right abstractions, it can be as
> simple to write a "script" in C or Lisp than it is to write it in
> shell or perl.  What is bad in these script language is their syntaxes
> and idiosyncraties.   What is good is the abstractions and "API" they
> offer (eg to manage jobs).  If they were implemented as a library for
> a high level programming language it would be perfect, but since
> they're designed as languages by people who cannot and should be
> forbidden to design languages, they're awful.
>
> A very bad example is perl.  A good example is scsh.
>
> --
> __Pascal Bourguignon__                    http://www.informatimago.com/
>
> NOTE: The most fundamental particles in this product are held
> together by a "gluing" force about which little is currently known
> and whose adhesive power can therefore not be permanently
> guaranteed.


Awesome! Amazing!!! Brilliant!!!
One question: Why does Name 6 not appear in the final file? does lisp
ignore the space and just test if 500>400 and then ignore it?
From: gavino
Subject: Re: script solution in common lisp
Date: 
Message-ID: <1184499005.789823.246580@d30g2000prg.googlegroups.com>
On Jul 15, 1:39 am, Pascal Bourguignon <····@informatimago.com> wrote:
> gavino <·········@gmail.com> writes:
> > I have a file named movie1.
> > name1,500
> > name2,yellow
>
> > I want to write a program/script that  reads the value from the file
> > next to a name, with 1 comma in between.
>
> You still cannot write it yourself???
> Have you been reading:
>
>     Common Lisp: A Gentle Introduction to Symbolic Computation
>     David S. Touretzky
>    http://www-cgi.cs.cmu.edu/afs/cs.cmu.edu/user/dst/www/LispBook/index....
>    http://www.cs.cmu.edu/~dst/LispBook/
> ?
>
> What chapter did you reach?  Did you do the exercises?
chapter 2 the caddr cddar stuff made my brain melt, I am taking a
guess I am supposed to skip it and not worry about it.  I mean I get
the concept of taking car of cdr so you can slice apart lists....
>
> > For a number it will test if x > 400.
> > For the string it will test if sting = green
> > If the test fails, the result should be a file named movie.error with
> > the name,value pairs that FAIL in the test.
>
> So far so good.
>
> > The real solution involves 25 different name,value pairs to be tested
> > as a subset of a 90 line name,value pair file; generated from 4,000
> > movies.
>
> I don't understand this "requirement".  Can you explain?
Our website has problems when the headers don't have correct data for
encrypted DRM movie titles.  A program can read the header from an
encrypted movie file.  The header is 90 lines.  25 lines are
important.  The value(right of the comma part) of 25 of these lines in
the form SomeName,SomeValue must match some numerical or string value
to be valid.  My task is to program the linux box containing all 4,000
encrypted titles to read the headers, and check the value to see if it
conforms to the "standard" number or string.  If not, make a list of
the titles, with the problem Name,value pairs indicated.

> > I am interested in how someone would do this in lisp.
>
> [···@thalassa tmp]$ ls -l movie.*
> -rw-r--r-- 1 pjb pjb  70 Jul 15 10:32 movie.data
> -rwxr-xr-x 1 pjb pjb 835 Jul 15 10:35 movie.script*
> [···@thalassa tmp]$ cat movie.script
> #!/usr/bin/clisp -q -ansi -Kfull -E utf-8
> ;; -*- mode:lisp;coding:utf-8 -*-
> (with-open-file (movie.error "movie.error" :direction :output
>                   :if-exists :append
>                   :if-does-not-exist :create)
>  (loop
>   :for line = (read-line *standard-input* nil nil)
>   :while line
>   :do (let ((comma (position #\, line)))
>         (when comma
>            (let* ((name   (subseq line 0 comma))
>                   (vfield (subseq line (1+ comma)))
>                   (value  (or (ignore-errors (parse-integer vfield
>                                                             :junk-allowed nil))
>                               vfield)))
>              (unless (if (integerp value)
>                        (> value 400)
>                        (string= value "green"))
>                  (format movie.error "~A,~A~%" name value)))))))
> [···@thalassa tmp]$ cat movie.data
> name1,500
> name2,yellow
> name3,300
> name4,green
> name5, green
> name6, 500
>
> [···@thalassa tmp]$ ./movie.script <movie.data
> [···@thalassa tmp]$ cat movie.error
> name2,yellow
> name3,300
> name5, green
> [···@thalassa tmp]$
>
> > I heard that high level languages also can do scripting as well.
>
> Scripts are programs, and high level programming languages are better
> than low level programming languages at creating programs, so no, high
> level programming languages cannot do scripting as well, they can to
> it better! :-)
>
> My point here is that given the right abstractions, it can be as
> simple to write a "script" in C or Lisp than it is to write it in
> shell or perl.  What is bad in these script language is their syntaxes
> and idiosyncraties.   What is good is the abstractions and "API" they
> offer (eg to manage jobs).  If they were implemented as a library for
> a high level programming language it would be perfect, but since
> they're designed as languages by people who cannot and should be
> forbidden to design languages, they're awful.
>
> A very bad example is perl.  A good example is scsh.
>
> --
> __Pascal Bourguignon__                    http://www.informatimago.com/
>
> NOTE: The most fundamental particles in this product are held
> together by a "gluing" force about which little is currently known
> and whose adhesive power can therefore not be permanently
> guaranteed.

Awesome! I knew lisp was up for low level dirt like this.
Amazingly, my bash solution works the same way, letting name6 pass
unscathed despite the space before the 500...
With the added pain of me having to look at the input file to
determine which lines were numeric vs text.
[·····@gavin bash]$ cat 2
#!/bin/sh
a=400
b=green

for i in 1 3 6; do if (( `grep name"$i" movie.data|cut -d, -f2` <
$a )); then grep name"$i" movie.data >>movie.error; fi; done
for i in 2 4 5; do if [[ `grep name"$i" movie.data|cut -d, -f2` !=
$b ]]; then grep name"$i" movie.data >>movie.error; fi; done

[·····@gavin bash]$ cat movie.error
name3,300
name2,yellow
name5, green
From: Jeronimo Pellegrini
Subject: Re: script solution in common lisp
Date: 
Message-ID: <f7d2l0$hpi$1@aioe.org>
On 2007-07-15, gavino <·········@gmail.com> wrote:
> On Jul 15, 1:39 am, Pascal Bourguignon <····@informatimago.com> wrote:
>> You still cannot write it yourself???
>> Have you been reading:
>>
>>     Common Lisp: A Gentle Introduction to Symbolic Computation
>>     David S. Touretzky
>>    http://www-cgi.cs.cmu.edu/afs/cs.cmu.edu/user/dst/www/LispBook/index....
>>    http://www.cs.cmu.edu/~dst/LispBook/
>> ?
>>
>> What chapter did you reach?  Did you do the exercises?
> chapter 2 the caddr cddar stuff made my brain melt, I am taking a
> guess I am supposed to skip it and not worry about it.  I mean I get
> the concept of taking car of cdr so you can slice apart lists....

I wouldn't use caddr and cddar if I were you. It obfuscates your code.
cadr and cdar should be enough, and you'll really understand the concept
when you need them. If I were you I'd skip that part and get abck to it
if necesary.

J.
From: Stefan Scholl
Subject: Re: script solution in common lisp
Date: 
Message-ID: <1T48fq3dIf4nNv8%stesch@parsec.no-spoon.de>
Jeronimo Pellegrini <···@aleph0.info> wrote:
> I wouldn't use caddr and cddar if I were you. It obfuscates your code.

But obfuscating is the new way. Look at Haskell! :-)


-- 
Web (en): http://www.no-spoon.de/ -*- Web (de): http://www.frell.de/
From: Kent M Pitman
Subject: Re: script solution in common lisp
Date: 
Message-ID: <u3azp9633.fsf@nhplace.com>
Stefan Scholl <······@no-spoon.de> writes:

> Jeronimo Pellegrini <···@aleph0.info> wrote:
> > I wouldn't use caddr and cddar if I were you. It obfuscates your code.
> 
> But obfuscating is the new way. Look at Haskell! :-)

The rule I used is never use any thing with an "a" following a "d",
since it isn't just a simple car access on the backbone, and never use
any a other than a leading one, since it's probably two abstractions
in one.  The only exception I know of is caar and cdar (or cadar if
you prefer), because they're alist accessors... but all in all, I'd make
abstractions even for those.
From: Christopher Browne
Subject: Re: script solution in common lisp
Date: 
Message-ID: <60ir8l3f6c.fsf@dba2.int.libertyrms.com>
gavino <·········@gmail.com> writes:
> On Jul 15, 1:39 am, Pascal Bourguignon <····@informatimago.com> wrote:
>> gavino <·········@gmail.com> writes:
>> > I have a file named movie1.
>> > name1,500
>> > name2,yellow
>>
>> > I want to write a program/script that  reads the value from the file
>> > next to a name, with 1 comma in between.
>>
>> You still cannot write it yourself???
>> Have you been reading:
>>
>>     Common Lisp: A Gentle Introduction to Symbolic Computation
>>     David S. Touretzky
>>    http://www-cgi.cs.cmu.edu/afs/cs.cmu.edu/user/dst/www/LispBook/index....
>>    http://www.cs.cmu.edu/~dst/LispBook/
>> ?
>>
>> What chapter did you reach?  Did you do the exercises?
> chapter 2 the caddr cddar stuff made my brain melt, I am taking a
> guess I am supposed to skip it and not worry about it.  I mean I get
> the concept of taking car of cdr so you can slice apart lists....

In the short run, beginners' code tends to be comprised of
"brain-melting" sets of c[ad]+r "Morse Code."

Unfortunately, this code tends to be about as impossible to coherently
read as it was to coherently write.

A number of things tend to happen as beginners advance; overall, the
programmer gets to get a lighter hand at this, knowing more tools to
use rather than just c[ad]+r, and how to use them:

1.  HEAD and REST, which actually describe "functionally" what's
happening, tend to get preferred, when actually "smashing" a list;

2.  Intelligent use of DEFSTRUCT and/or DEFCLASS provide more
application-specific data structures, which is one of the additional
tools;

3.  Knowing when to split off functions ("refactor" is the term that
gets used a lot) often allows individual functions to become simpler,
which gets rid of the need to do wacky "factorings" of lists;

4.  DESTRUCTURING-BIND and similar macros can replace wacky
refactorings of lists with a "Word of Faith" approach
(<http://en.wikipedia.org/wiki/Word_of_Faith>) where you "Name it and
Claim it."

Many languages have this "battle" where beginners wind up having
dauntingly awful code where there's some confusion over the use of
data structures.

- In FORTH, there's an analagous problem with "stack smashing" where
  beginners do gratuitous amounts of rotating of the contents of the
  stack.

- In Pascal, nestings of names (and abuses, or cases of spectacular
  potential for confusion of lexical scoping) tend to result.

- In C, overexuberant pointer manipulations are commonly an early
  problem; I'm not sure it lets up :-(.
-- 
let name="cbbrowne" and tld="acm.org" in String.concat ·@" [name;tld];;
http://www3.sympatico.ca/cbbrowne/languages.html
"Without  insects,  our ecosystem  would  collapse  and  we would  all
die.  In  that respect,  insects  are  far  more important  than  mere
end-users."  -- Eugene O'Neil <······@cs.umb.edu>
From: Slobodan Blazeski
Subject: Re: script solution in common lisp
Date: 
Message-ID: <1184572510.560537.10110@n2g2000hse.googlegroups.com>
On Jul 15, 4:38 pm, Christopher Browne <········@mail.libertyrms.com>
wrote:
> gavino <·········@gmail.com> writes:
> > On Jul 15, 1:39 am, Pascal Bourguignon <····@informatimago.com> wrote:
> >> gavino <·········@gmail.com> writes:
> >> > I have a file named movie1.
> >> > name1,500
> >> > name2,yellow
>
> >> > I want to write a program/script that  reads the value from the file
> >> > next to a name, with 1 comma in between.
>
> >> You still cannot write it yourself???
> >> Have you been reading:
>
> >>     Common Lisp: A Gentle Introduction to Symbolic Computation
> >>     David S. Touretzky
> >>    http://www-cgi.cs.cmu.edu/afs/cs.cmu.edu/user/dst/www/LispBook/index....
> >>    http://www.cs.cmu.edu/~dst/LispBook/
> >> ?
>
> >> What chapter did you reach?  Did you do the exercises?
> > chapter 2 the caddr cddar stuff made my brain melt, I am taking a
> > guess I am supposed to skip it and not worry about it.  I mean I get
> > the concept of taking car of cdr so you can slice apart lists....
>
> In the short run, beginners' code tends to be comprised of
> "brain-melting" sets of c[ad]+r "Morse Code."
>
> Unfortunately, this code tends to be about as impossible to coherently
> read as it was to coherently write.
>
> A number of things tend to happen as beginners advance; overall, the
> programmer gets to get a lighter hand at this, knowing more tools to
> use rather than just c[ad]+r, and how to use them:
>
> 1.  HEAD and REST, which actually describe "functionally" what's
> happening, tend to get preferred, when actually "smashing" a list;
>
> 2.  Intelligent use of DEFSTRUCT and/or DEFCLASS provide more
> application-specific data structures, which is one of the additional
> tools;
>
> 3.  Knowing when to split off functions ("refactor" is the term that
> gets used a lot) often allows individual functions to become simpler,
> which gets rid of the need to do wacky "factorings" of lists;
>
> 4.  DESTRUCTURING-BIND and similar macros can replace wacky
> refactorings of lists with a "Word of Faith" approach
> (<http://en.wikipedia.org/wiki/Word_of_Faith>) where you "Name it and
> Claim it."

I'm not sure that I understand what are you saying at #4. Something
like SICP's if you don't know it's name and show it in your code than
you can't summon it's power? Or ...?
From: Christopher Browne
Subject: Re: script solution in common lisp
Date: 
Message-ID: <60tzs4whc6.fsf@dba2.int.libertyrms.com>
Slobodan Blazeski <·················@gmail.com> writes:
> On Jul 15, 4:38 pm, Christopher Browne <········@mail.libertyrms.com>
> wrote:
>> 4.  DESTRUCTURING-BIND and similar macros can replace wacky
>> refactorings of lists with a "Word of Faith" approach
>> (<http://en.wikipedia.org/wiki/Word_of_Faith>) where you "Name it and
>> Claim it."
>
> I'm not sure that I understand what are you saying at #4. Something
> like SICP's if you don't know it's name and show it in your code than
> you can't summon it's power? Or ...?

No, just an overly-baroque American joke alongside the notion that you
can grab elements of a list and bind them directly to symbol names
using things like DESTRUCTURING-BIND.

Name it and access it...
-- 
output = reverse("gro.mca" ·@" "enworbbc")
http://www3.sympatico.ca/cbbrowne/lisp.html
"It   can be   shown   that for any  nutty  theory,  beyond-the-fringe
political view or  strange religion there  exists  a proponent  on the
Net. The proof is left as an exercise for your kill-file."
-- Bertil Jonell
From: Pascal Bourguignon
Subject: Re: script solution in common lisp
Date: 
Message-ID: <87ps2soehn.fsf@thalassa.lan.informatimago.com>
gavino <·········@gmail.com> writes:

> On Jul 15, 1:39 am, Pascal Bourguignon <····@informatimago.com> wrote:
>> gavino <·········@gmail.com> writes:
>> > I have a file named movie1.
>> > name1,500
>> > name2,yellow
>>
>> > I want to write a program/script that  reads the value from the file
>> > next to a name, with 1 comma in between.
>>
>> You still cannot write it yourself???
>> Have you been reading:
>>
>>     Common Lisp: A Gentle Introduction to Symbolic Computation
>>     David S. Touretzky
>>    http://www-cgi.cs.cmu.edu/afs/cs.cmu.edu/user/dst/www/LispBook/index....
>>    http://www.cs.cmu.edu/~dst/LispBook/
>> ?
>>
>> What chapter did you reach?  Did you do the exercises?
> chapter 2 the caddr cddar stuff made my brain melt, I am taking a
> guess I am supposed to skip it and not worry about it.  I mean I get
> the concept of taking car of cdr so you can slice apart lists....

You should persevere.  Even if you don't use CADDR and CDDAR everyday
in lisp programming, the point is to do these exercises to train your
brain and gain some illumination (eg. on why functional abstraction is
a good thing).
 

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

NOTE: The most fundamental particles in this product are held
together by a "gluing" force about which little is currently known
and whose adhesive power can therefore not be permanently
guaranteed.
From: gavino
Subject: Re: script solution in common lisp
Date: 
Message-ID: <1185668906.360869.240780@i13g2000prf.googlegroups.com>
On Jul 15, 1:39 am, Pascal Bourguignon <····@informatimago.com> wrote:
> gavino<·········@gmail.com> writes:
> > I have a file named movie1.
> > name1,500
> > name2,yellow
>
> > I want to write a program/script that  reads the value from the file
> > next to a name, with 1 comma in between.
>
> You still cannot write it yourself???
> Have you been reading:
>
>     Common Lisp: A Gentle Introduction to Symbolic Computation
>     David S. Touretzky
>    http://www-cgi.cs.cmu.edu/afs/cs.cmu.edu/user/dst/www/LispBook/index....
>    http://www.cs.cmu.edu/~dst/LispBook/
> ?
>
> What chapter did you reach?  Did you do the exercises?
>
> > For a number it will test if x > 400.
> > For the string it will test if sting = green
> > If the test fails, the result should be a file named movie.error with
> > the name,value pairs that FAIL in the test.
>
> So far so good.
>
> > The real solution involves 25 different name,value pairs to be tested
> > as a subset of a 90 line name,value pair file; generated from 4,000
> > movies.
>
> I don't understand this "requirement".  Can you explain?
>
> > I am interested in how someone would do this in lisp.
>
> [···@thalassa tmp]$ ls -l movie.*
> -rw-r--r-- 1 pjb pjb  70 Jul 15 10:32 movie.data
> -rwxr-xr-x 1 pjb pjb 835 Jul 15 10:35 movie.script*
> [···@thalassa tmp]$ cat movie.script
> #!/usr/bin/clisp -q -ansi -Kfull -E utf-8
> ;; -*- mode:lisp;coding:utf-8 -*-
> (with-open-file (movie.error "movie.error" :direction :output
>                   :if-exists :append
>                   :if-does-not-exist :create)
>  (loop
>   :for line = (read-line *standard-input* nil nil)
>   :while line
>   :do (let ((comma (position #\, line)))
>         (when comma
>            (let* ((name   (subseq line 0 comma))
>                   (vfield (subseq line (1+ comma)))
>                   (value  (or (ignore-errors (parse-integer vfield
>                                                             :junk-allowed nil))
>                               vfield)))
>              (unless (if (integerp value)
>                        (> value 400)
>                        (string= value "green"))
>                  (format movie.error "~A,~A~%" name value)))))))
> [···@thalassa tmp]$ cat movie.data
> name1,500
> name2,yellow
> name3,300
> name4,green
> name5, green
> name6, 500
>
> [···@thalassa tmp]$ ./movie.script <movie.data
> [···@thalassa tmp]$ cat movie.error
> name2,yellow
> name3,300
> name5, green
> [···@thalassa tmp]$
>
> > I heard that high level languages also can do scripting as well.
>
> Scripts are programs, and high level programming languages are better
> than low level programming languages at creating programs, so no, high
> level programming languages cannot do scripting as well, they can to
> it better! :-)
>
> My point here is that given the right abstractions, it can be as
> simple to write a "script" in C or Lisp than it is to write it in
> shell or perl.  What is bad in these script language is their syntaxes
> and idiosyncraties.   What is good is the abstractions and "API" they
> offer (eg to manage jobs).  If they were implemented as a library for
> a high level programming language it would be perfect, but since
> they're designed as languages by people who cannot and should be
> forbidden to design languages, they're awful.
>
> A very bad example is perl.  A good example is scsh.
>
> --
> __Pascal Bourguignon__                    http://www.informatimago.com/
>
> NOTE: The most fundamental particles in this product are held
> together by a "gluing" force about which little is currently known
> and whose adhesive power can therefore not be permanently
> guaranteed.

Wow, now will I understand how that lisp program works once I finish
the tourestsky book?  the Utf 8 and other setup stuff at the top of
the program is very mysterious to me.
   #!/usr/bin/clisp -q -ansi -Kfull -E utf-8
   ;; -*- mode:lisp;coding:utf-8 -*-
Also the exciting part is that I assume that the list of values to
check can be added to.
The actual task I am working on involves doing 25 tests on a file.
Then there are 3400 files to test.
I still find it curious that name6 escaped while name 5 did not.  That
means that the interpreter treated " 500" the same as "500".  This is
impressive though and very motivating to me to finish Touretsky and
move on to Siebel or Graham etc.
From: Frank Buss
Subject: Re: script solution in common lisp
Date: 
Message-ID: <1pxgarmbxskyr$.1imwrj51pm46u.dlg@40tude.net>
gavino wrote:

> Wow, now will I understand how that lisp program works once I finish
> the tourestsky book?  the Utf 8 and other setup stuff at the top of
> the program is very mysterious to me.
>    #!/usr/bin/clisp -q -ansi -Kfull -E utf-8

There is nothing mysterious if you read the manual:
http://clisp.cons.org/clisp.html

>    ;; -*- mode:lisp;coding:utf-8 -*-

Same for this line.
http://www.gnu.org/software/emacs/manual/html_node/emacs/Specifying-File-Variables.html

> I still find it curious that name6 escaped while name 5 did not.  That
> means that the interpreter treated " 500" the same as "500".  This is
> impressive though and very motivating to me to finish Touretsky and
> move on to Siebel or Graham etc.

I don't see why this is impressive, just read the manual:

http://www.lispworks.com/documentation/HyperSpec/Body/f_parse_.htm :

| Optional leading and trailing whitespace is ignored.

-- 
Frank Buss, ··@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de
From: gavino
Subject: Re: script solution in common lisp
Date: 
Message-ID: <1185924435.000822.276550@57g2000hsv.googlegroups.com>
On Jul 15, 1:39 am, Pascal Bourguignon <····@informatimago.com> wrote:
> gavino <·········@gmail.com> writes:
> > I have a file named movie1.
> > name1,500
> > name2,yellow
>
> > I want to write a program/script that  reads the value from the file
> > next to a name, with 1 comma in between.
>
> You still cannot write it yourself???
> Have you been reading:
>
>     Common Lisp: A Gentle Introduction to Symbolic Computation
>     David S. Touretzky
>    http://www-cgi.cs.cmu.edu/afs/cs.cmu.edu/user/dst/www/LispBook/index....
>    http://www.cs.cmu.edu/~dst/LispBook/
> ?
>
> What chapter did you reach?  Did you do the exercises?
>
> > For a number it will test if x > 400.
> > For the string it will test if sting = green
> > If the test fails, the result should be a file named movie.error with
> > the name,value pairs that FAIL in the test.
>
> So far so good.
>
> > The real solution involves 25 different name,value pairs to be tested
> > as a subset of a 90 line name,value pair file; generated from 4,000
> > movies.
>
> I don't understand this "requirement".  Can you explain?
>
> > I am interested in how someone would do this in lisp.
>
> [···@thalassa tmp]$ ls -l movie.*
> -rw-r--r-- 1 pjb pjb  70 Jul 15 10:32 movie.data
> -rwxr-xr-x 1 pjb pjb 835 Jul 15 10:35 movie.script*
> [···@thalassa tmp]$ cat movie.script
> #!/usr/bin/clisp -q -ansi -Kfull -E utf-8
> ;; -*- mode:lisp;coding:utf-8 -*-
> (with-open-file (movie.error "movie.error" :direction :output
>                   :if-exists :append
>                   :if-does-not-exist :create)
>  (loop
>   :for line = (read-line *standard-input* nil nil)
>   :while line
>   :do (let ((comma (position #\, line)))
>         (when comma
>            (let* ((name   (subseq line 0 comma))
>                   (vfield (subseq line (1+ comma)))
>                   (value  (or (ignore-errors (parse-integer vfield
>                                                             :junk-allowed nil))
>                               vfield)))
>              (unless (if (integerp value)
>                        (> value 400)
>                        (string= value "green"))
>                  (format movie.error "~A,~A~%" name value)))))))
> [···@thalassa tmp]$ cat movie.data
> name1,500
> name2,yellow
> name3,300
> name4,green
> name5, green
> name6, 500
>
> [···@thalassa tmp]$ ./movie.script <movie.data
> [···@thalassa tmp]$ cat movie.error
> name2,yellow
> name3,300
> name5, green
> [···@thalassa tmp]$
>
> > I heard that high level languages also can do scripting as well.
>
> Scripts are programs, and high level programming languages are better
> than low level programming languages at creating programs, so no, high
> level programming languages cannot do scripting as well, they can to
> it better! :-)
>
> My point here is that given the right abstractions, it can be as
> simple to write a "script" in C or Lisp than it is to write it in
> shell or perl.  What is bad in these script language is their syntaxes
> and idiosyncraties.   What is good is the abstractions and "API" they
> offer (eg to manage jobs).  If they were implemented as a library for
> a high level programming language it would be perfect, but since
> they're designed as languages by people who cannot and should be
> forbidden to design languages, they're awful.
>
> A very bad example is perl.  A good example is scsh.
>
> --
> __Pascal Bourguignon__                    http://www.informatimago.com/
>
> NOTE: The most fundamental particles in this product are held
> together by a "gluing" force about which little is currently known
> and whose adhesive power can therefore not be permanently
> guaranteed.

This example script works perfectly.
I compiled clisp 2.41 on redhat 4AS gcc 3.4 including libsigsedv and
readline..
Now to refine my problem statement:
There are 20 string, and 10 numerical, tests to be performed on each
of 3400 files.
So about 30 of these 'tests' to run on EACH file.
I can do a simple loop in bash....but some of the values have quotes
around the value so the name,value pair takes the form of
name,"value"...and I am wondering if the lisp interpreter will be
confused by that?
Also, how should I add the specific name,value tests?  I am
considering how to rewrite the unless section....
From: Brian Adkins
Subject: Re: script solution in common lisp
Date: 
Message-ID: <1185861240.173427.252330@o61g2000hsh.googlegroups.com>
On Jul 15, 1:58 am, gavino <·········@gmail.com> wrote:
> I have a file named movie1.
> name1,500
> name2,yellow
>
> I want to write a program/script that  reads the value from the file
> next to a name, with 1 comma in between.
> For a number it will test if x > 400.
> For the string it will test if sting = green
> If the test fails, the result should be a file named movie.error with
> the name,value pairs that FAIL in the test.
> The real solution involves 25 different name,value pairs to be tested
> as a subset of a 90 line name,value pair file; generated from 4,000
> movies.
> I am interested in how someone would do this in lisp.
> I heard that high level languages also can do scripting as well.

Right tool for the job...

1  while line = gets
2    name,value = line.gsub(/\s+/,'').split(',')
3    if value =~ /\d+/
4      puts "#{name},#{value}" unless value.to_i > 400
5    else
6      puts "#{name},#{value}" unless value == 'green'
7    end
8  end

ruby movie.rb < movie.data > movie.error