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

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

Derek,

Ok, enough people have said "check each for non white-space" is faster, so
I'll use that.  My thought was that if there was a way to do it in a native
Euphoria routine that it would be fastest, 'cause it might be doing that
very same check but in c code.  Thanks.

Dan

----- Original Message -----
From: "Derek Parnell" <Derek.Parnell at SYD.RABOBANK.COM>
To: "EUforum" <EUforum at topica.com>
Subject: RE: find if any memers of a set are in another set (blank line fi
nder)?


>
> Dan,
> the fastest is just to check each character until you get a non-whitespace
> one.
>
>
> -------
> sequence x
>
> x = {
>     "                    ",
>     "          \t \n\r",
>     "                   a",
>     "a                   ",
>     ""
> }
>
> atom e
> e =time()
> for j = 1 to 1000000  do
> for i = 1 to length(x) do
>
>     for k = 1 to length(x[i]) do
>         if find(x[i][k], " \n\t\r") = 0 then
>             exit
>         end if
>     end for
> end for
>
> end for
>
> printf(1, "%f", time()-e)
> ------------
>
> This takes about 4.5 seconds on my machine.
>
> > -----Original Message-----
> > From: Dan Moyer [mailto:DANIELMOYER at prodigy.net]
> > Sent: Thursday, 18 July 2002 23:11
> > To: EUforum
> > Subject: Re: find if any memers of a set are in another set
> > (blank line
> > finder)?
> >
> >
> > 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?
> >
> > 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"
<snip>

>
>
>
>

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

Search



Quick Links

User menu

Not signed in.

Misc Menu