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.
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 ***
(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")
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
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.
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
(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")