1. RE: find if any memers of a set are in another set (blank line
- Posted by Derek Parnell <Derek.Parnell at SYD.RABOBANK.COM> Jul 18, 2002
- 372 views
This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_000_01C22EAB.042F01B0 charset=iso-8859-1 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" > > (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 > > > > > > > ================================================================== De informatie opgenomen in dit bericht kan vertrouwelijk zijn en is uitsluitend bestemd voor de geadresseerde. Indien u dit bericht onterecht ontvangt wordt u verzocht de inhoud niet te gebruiken en de afzender direct te informeren door het bericht te retourneren. ================================================================== The information contained in this message may be confidential and is intended to be exclusively for the addressee. Should you receive this message unintentionally, please do not use the contents herein and notify the sender immediately by return e-mail. ================================================================== ------_=_NextPart_000_01C22EAB.042F01B0 Content-Type: application/ms-tnef