[Prev][Next][Index][Thread]

Re: Critique a first prog?



In article <39CA550D.7964C1F8@jenkon.com>,
  Bryn Keller <brk@jenkon.com> wrote:
> Hello,
>     I'm new to Dylan, and I don't know anyone personally who knows
> Dylan, so I'm posting my first Dylan program here for everyone to pick
> apart.

Hi Bryn,

Welcome!   You're off to a good start.   I have a few suggestions for
you.

1. I think you can write your good-line? function as

  define function good-line? (line) => (answer :: <boolean>)
   let bad = #["SRC=next.gif", "<HTML>", "<BODY", "<!DOCTYPE", "HEAD>",
"<TITLE>", "<ADDRESS>", "</HTML>", "</BODY", "<LINK", "<META", "<DIV",
"</DIV"];
   ~any?(curry(subsequence-position, line), bad);
  end;

I think that should work.

2. Use empty? instead of size == 0.  Ex:
     if (empty?(arguments))

3. Use the with-open-file macro for opening and closing files

4. You can use read-line like this:

  let line = #f;
  while(line := read-line(input, on-end-of-stream: #f))
    add!(lines, line);
  end;

Good luck!


Sent via Deja.com http://www.deja.com/
Before you buy.



References: