From: anders
Subject: Some expert comment please
Date: 
Message-ID: <1185821750.897199.140250@q75g2000hsh.googlegroups.com>
I have write my "first" useful program,
i looks in a catalog för files ending on .tmp
and erase them, could make it on 1 line
with batch, but i like to use LISP.

So i came upp with follow
----------------------------------------------------------
(defvar *content* (directory "*.tmp"))

(dolist (file-name *content*)
     (delete-file file-name))
----------------------------------------------------------

Any comment ?
Regarding should/should not,
This is better etc.

Tankfull for en expert comment.

From: Barry Margolin
Subject: Re: Some expert comment please
Date: 
Message-ID: <barmar-A0F1E4.22114730072007@newsgroups.comcast.net>
In article <························@q75g2000hsh.googlegroups.com>,
 anders <················@gmail.com> wrote:

> I have write my "first" useful program,
> i looks in a catalog f�r files ending on .tmp
> and erase them, could make it on 1 line
> with batch, but i like to use LISP.
> 
> So i came upp with follow
> ----------------------------------------------------------
> (defvar *content* (directory "*.tmp"))
> 
> (dolist (file-name *content*)
>      (delete-file file-name))
> ----------------------------------------------------------
> 
> Any comment ?
> Regarding should/should not,
> This is better etc.
> 
> Tankfull for en expert comment.

DEFVAR only assigns the default value to a variable if it doesn't 
already have a value.  So if you use this code twice, the second time it 
will try to delete the files that it deleted the first time, rather than 
look up the current list of *.tmp files.

In general, DEFVAR should be used for global variables that you plan on  
referencing from multiple places, or that the may want to assign to.  If 
you just want a temporary name within a piece of code, use LET to create 
a local variable:

(let ((content (directory "*.tmp")))
  (dolist (file-name content)
    (delete-file file-name)))

-- 
Barry Margolin, ······@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
From: Alex Mizrahi
Subject: Re: Some expert comment please
Date: 
Message-ID: <46ae44a2$0$90262$14726298@news.sunsite.dk>
(message (Hello 'anders)
(you :wrote  :on '(Mon, 30 Jul 2007 11:55:50 -0700))
(

 a> and erase them, could make it on 1 line
 a> with batch, but i like to use LISP.

 a> Any comment ?

certainly this doesn't make big difference, but you can make it in one line 
in lisp too:

(mapcar #'delete-file (directory "*.tmp"))

)
(With-best-regards '(Alex Mizrahi) :aka 'killer_storm)
"choose no life") 
From: Cesar Rabak
Subject: Re: Some expert comment please
Date: 
Message-ID: <46AE9B9E.80702@yahoo.com.br>
Alex Mizrahi escreveu:
> (message (Hello 'anders)
> (you :wrote  :on '(Mon, 30 Jul 2007 11:55:50 -0700))
> (
> 
>  a> and erase them, could make it on 1 line
>  a> with batch, but i like to use LISP.
> 
>  a> Any comment ?
> 
> certainly this doesn't make big difference, but you can make it in one line 
> in lisp too:
> 
> (mapcar #'delete-file (directory "*.tmp"))
> 
Thanks you did it fast Alex otherwise we could get some froggy language 
showing us a 100% improvement LOC-wise :-P
From: Slobodan Blazeski
Subject: Re: Some expert comment please
Date: 
Message-ID: <1185878235.720054.138940@k79g2000hse.googlegroups.com>
On Jul 31, 4:17 am, Cesar Rabak <·······@yahoo.com.br> wrote:
> Alex Mizrahi escreveu:> (message (Hello 'anders)
> > (you :wrote  :on '(Mon, 30 Jul 2007 11:55:50 -0700))
> > (
>
> >  a> and erase them, could make it on 1 line
> >  a> with batch, but i like to use LISP.
>
> >  a> Any comment ?
>
> > certainly this doesn't make big difference, but you can make it in one line
> > in lisp too:
>
> > (mapcar #'delete-file (directory "*.tmp"))
>
> Thanks you did it fast Alex otherwise we could get some froggy language
> showing us a 100% improvement LOC-wise :-P

LOL, now we could focus on inmproving the character count.
From: Matthias Benkard
Subject: Re: Some expert comment please
Date: 
Message-ID: <1185915987.258278.157650@k79g2000hse.googlegroups.com>
Hi,

> LOL, now we could focus on inmproving the character count.

I'll start by suggesting replacing MAPCAR with MAPC. :)

Mata ne,
Matthias
From: Slobodan Blazeski
Subject: Re: Some expert comment please
Date: 
Message-ID: <1185953338.489572.90850@r34g2000hsd.googlegroups.com>
On Jul 31, 11:06 pm, Matthias Benkard <··········@gmail.com> wrote:
> Hi,
>
> > LOL, now we could focus on inmproving the character count.
>
> I'll start by suggesting replacing MAPCAR with MAPC. :)
>
> Mata ne,
> Matthias

Nobody should post anything untill a programm looks like this :
(i *.tmp)  or shorter and be carefull not to put any extra spaces.
For any ideas see:
http://www.ariel.com.au/jokes/The_Evolution_of_a_Programmer.html
From: Alex Mizrahi
Subject: Re: Some expert comment please
Date: 
Message-ID: <46b1e99a$0$90267$14726298@news.sunsite.dk>
(message (Hello 'Slobodan)
(you :wrote  :on '(Wed, 01 Aug 2007 00:28:58 -0700))
(

 ??>>> LOL, now we could focus on inmproving the character count.
 ??>>
 ??>> I'll start by suggesting replacing MAPCAR with MAPC. :)

 SB> Nobody should post anything untill a programm looks like this :
 SB> (i *.tmp)  or shorter and be carefull not to put any extra spaces.

have you seen Arc programs by Paul Graham?

http://news.ycombinator.com/item?id=32766

(def codetree (file)
   (trav + 1 (readall (infile file))))

(len (flat (readall (infile file))))

 (def codelines (file)
   (w/infile in file
     (summing test
       (whilet line (readline in)
         (test (aand (find nonwhite line) (isnt it #\;)))))))

(def trav (f base tree)
   (if (atom tree)
       (base tree)
       (f (trav f base (car tree)) (trav f base (cdr tree)))))

 (def copy-tree (tree) (trav cons (fn (x) x) tree))

does'n this look uber-cool? :)
especially i like (insnt it #\;) thing


)
(With-best-regards '(Alex Mizrahi) :aka 'killer_storm)
"choose no life")