Re: find if any memers of a set are in another set (blank line finder)?
- Posted by cetaylor at compuserve.com Jul 18, 2002
- 395 views
Dan, A type can be used just like a function that returns TRUE or FALSE. If it makes you feel better you can use a function call instead of a type call (just substitute the word "function" for "type" in the code). Use it like this: if blank_line(line) then -- do this else -- do that end if Testing character by character will usually be faster than testing the whole string, since the routine exits at the first non-whitespace character it finds. Colin Taylor ----- Original Message ----- From: "Dan Moyer" <DANIELMOYER at prodigy.net> To: "EUforum" <EUforum at topica.com> Sent: Thursday, July 18, 2002 5:38 PM Subject: Re: find if any memers of a set are in another set (blank line finder)? > > > Colin, > > I did think of that, but I haven't made user-defined types before & when I > read the manual, I thought it said that if your program encounters something > in a user-typed variable that isn't the right type, the program *halts* & > gives an error message. That wouldn't be what I wanted at all! Did I > misunderstand the manual? > > Dan > > > ----- Original Message ----- > From: <cetaylor at compuserve.com> > > > > > Dan, > > > > Sometimes the direct approach is the simplest and fastest: > > --- > > type blank_line(sequence s) > > for i = 1 to length(s) do > > if not find(s[i], " \t\n") then > > return 0 > > end if > > end for > > return 1 > > end type > > --- > > > > Colin Taylor > > > > > >