Re: find if any memers of a set are in another set (blank line finder)?

new topic     » goto parent     » topic index » view thread      » older message » newer message

On 18 Jul 2002, at 5:59, Dan Moyer wrote:

> 
> I haven't tested this yet against text read in from a file, but it seems
> like it *might* work, does anyone have any thing better/faster?  When I put a
> tab in sequence "a" below, it didn't like that, but I think a tab in a file
> might be different?

A tab is ascii 9, doesn't matter where you get it from.

This is a lil shorter than what you have below:

include strtok-v2.e

line = "                 " -- or whatever
junk = parse(line,32) -- 32 is ascii for blank, or ' ' or " "
if length(junk) = 0 
 then -- it's blank
 else -- it's not blank
end if

Here is a way to see if there is any member of a set in a string:

punctset = "-_^`'<>][?*\\/}{+&^ at !~|;:,."
line = "a b at Cat.d"

junk = parse(line,punctset)
if length(junk) > 1  
  then -- length is how many of punctset in line
  else -- none of punctset is in line
end if

Kat

> Dan Moyer
> 
> <code begins>
> sequence a, b
> a = "      "
> b = "this is a line of text!"
> 
> function IsBlankLine(sequence aLine)
>   sequence w,x
>   w = aLine
>   x = w
>   w = w > 32  -- catches any characters *less* than 33
>   x = w < 126 -- catches any characters more than 126
>   w = w and x
> 
>   if find(1,w) then
>      return 0 -- no, is *not* blank line
>   else
>      return 1 -- yes, is blank line
>   end if
> end function
> 
> if IsBlankLine(a) = 1 then
>     puts(1, "yes, \"" & a & "\" is a blank line")
> else
>    puts(1, "no, \"" & a & "\" is  not a blank line")
> end if
> puts(1, "\n")
> if IsBlankLine(b) = 1 then
>     puts(1, "yes, \"" & b & "\" is a blank line")
> else
>    puts(1, "no, \"" & b & "\" is  not a blank line")
> end if
> 
> <code ends>
> 
> 
> ----- Original Message -----
> From: "Dan Moyer" <DANIELMOYER at prodigy.net>
> To: "EUforum" <EUforum at topica.com>
> Sent: Thursday, July 18, 2002 5:19 AM
> Subject: find if any memers of a set are in another set (blank line finder)?
> 
> 
> > I want to be able to discern whether a sequence (a line of text) is
> "empty"
> > (ie, has *only* spaces or tabs or CR or any combination of those), or if
> it
> > has *any* alpha/num/punctuation content at all.  In other words,a "blank"
> > line
> > finder.  And it needs to function as quickly as possible.
> >
> > I thought there might be a spiffy way similar to how:
> >
> > w = {1, 2, 3} = {1, 2, 4}  gives: w={1,1,0}
> >
> > and then I could make a sequence of the numbers 33-126 (for all the
> > al/num/punc), and test any line against that sequence with an "or" in
> place
> > of the "="; but as a test,
> >
> > w = {1, 2, 3} or {1, 2, 4} gives me:  w= {1,1,1}, which I don't
> understand.
> > (I'm thinking it means that neither 3 nor 4 are zero.)
> >
> > So, is there some way to find if any member of a given set is found in
> > another set, or some different, good (fast) way to find "blank" lines?
> >
> > Dan Moyer
> >
> >
> 
> 
>

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu