Newsgroups: comp.lang.lisp
From: Thom Goodsell <t...@cra.com>
Date: 2000/06/22
Subject: Re: Newbie asking for help
> (with-open-file (ifile "key.html" :direction :input) Ok, a few suggestions, then. As Erik mentioned, nlines is a free > (setf nlines 0) > (loop > (if (read-line ifile nil nil) > (setf nlines (+ 1 nlines)) > (return (print nlines))))) > So, i plod along, undaunted... variable. Use a let form. It's probably stylistic, but I prefer the much-more-compact (incf) function to using (set x (+ 1 x)). Also, you can replace the if construct with features of the loop facility -- use while and finally. Some people may argue this stylistically, but I like prefer it [1]. So, the revised, slightly cleaner code looks like this: (with-open-file (ifile "key.html" :direction :input) The even more compact version uses the for and from loop functionality: (with-open-file (ifile "key.html" :direction :input) Thom [1] I learned my Lisp somewhat in a vacuum, so I sometimes find that Thom Goodsell You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||