1. Find what?
- Posted by Paul Kerslake <paulk at UNISERVE.COM> Nov 06, 2000
- 479 views
------=_NextPart_000_0029_01C04806.4E6F6220 charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi evr'yone I was wondering about find(). What if there are 2 of the same characters = in a sequence? Like this: sequence word word=3D"beet" atom findit findit=3Dfind("e", word) ? findit Does it give a [2..3] back? -->Thanks --->Thomas -------/\=3D=3D=3D=3D ------=_NextPart_000_0029_01C04806.4E6F6220 charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META content=3D"text/html; charset=3Diso-8859-1" = http-equiv=3DContent-Type> <META content=3D"MSHTML 5.00.2614.3500" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV><FONT face=3DArial size=3D2>Hi evr'yone</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>I was wondering about find(). What if = there are 2=20 of the same characters in a sequence? Like this:</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>sequence word</FONT></DIV> <DIV><FONT face=3DArial size=3D2>word=3D"beet"</FONT></DIV> <DIV><FONT face=3DArial size=3D2>atom findit</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>findit=3Dfind("e", word)</FONT></DIV> <DIV><FONT face=3DArial size=3D2>? findit</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>Does it give a [2..3] = back?</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>-->Thanks</FONT></DIV> <DIV><FONT face=3DArial size=3D2>--->Thomas</FONT></DIV> <DIV><FONT face=3DArial = ------=_NextPart_000_0029_01C04806.4E6F6220--
2. Re: Find what?
- Posted by Derek Parnell <dparnell at BIGPOND.NET.AU> Nov 07, 2000
- 441 views
------=_NextPart_000_02AB_01C048A7.CD71CEE0 charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi Thomas, no it doesn't return a sequence. >From the manual:- find Syntax: i =3D find(x, s) =20 Description: Find x as an element of s. If successful, return the = index of the first element of s that matches. If unsuccessful return 0. = Note the key phrase in the manual "index of the first element". To find all occurrences try this... sequence result, word integer x result =3D {} word =3D "experience" for i =3D 1 to length(word) do x =3D find('e', word) if x then result &=3D x end if end for ? result -- Should display {1,4,7,10} ------ Derek Parnell Melbourne, Australia (Vote [1] The Cheshire Cat for Internet Mascot) ----- Original Message -----=20 From: Paul Kerslake=20 To: EUPHORIA at LISTSERV.MUOHIO.EDU=20 Sent: Tuesday, November 07, 2000 10:29 AM Subject: Find what? Hi evr'yone I was wondering about find(). What if there are 2 of the same = characters in a sequence? Like this: sequence word word=3D"beet" atom findit findit=3Dfind("e", word) ? findit Does it give a [2..3] back? -->Thanks --->Thomas -------/\=3D=3D=3D=3D ------=_NextPart_000_02AB_01C048A7.CD71CEE0 charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=3DContent-Type content=3D"text/html; = charset=3Diso-8859-1"> <META content=3D"MSHTML 5.50.4207.2601" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV><FONT face=3DArial size=3D2>Hi Thomas,</FONT></DIV> <DIV><FONT face=3DArial size=3D2>no it doesn't return a = sequence.</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>From the manual:-</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV> <CENTER><B>find</B></CENTER> <P> <TABLE cellSpacing=3D2 cellPadding=3D2 border=3D0> <TBODY> <TR> <TD vAlign=3Dtop><B>Syntax:</B></TD> <TD><FONT face=3D"Arial, Helvetica">i =3D find(x, s) = </FONT></TD></TR> <TR> <TD vAlign=3Dtop><B>Description:</B></TD> <TD>Find x as an element of s. If successful, return the index of = the=20 first element of s that matches. If unsuccessful return 0.=20 </TD></TR></TBODY></TABLE></P> <P><FONT face=3DArial size=3D2></FONT> </P> <P><FONT face=3DArial size=3D2>Note the key phrase in the manual "index = of the=20 <STRONG>first</STRONG> element".</FONT></P> <P><FONT face=3DArial size=3D2>To find all occurrences try = this...</FONT></P> <P><FONT size=3D2>sequence result, word<BR>integer x<BR></FONT><FONT = size=3D2>result=20 =3D {}<BR>word =3D "experience"</FONT><FONT size=3D2><BR>for i =3D 1 to = length(word)=20 do<BR> x =3D find('e', word)<BR> if x = then<BR> =20 result &=3D x<BR> end if<BR>end for<BR>? result -- Should = display=20 {1,4,7,10}</FONT></P></DIV> <DIV>------<BR>Derek Parnell<BR>Melbourne, Australia<BR>(Vote [1] The = Cheshire=20 Cat for Internet Mascot)<BR></DIV> <BLOCKQUOTE dir=3Dltr=20 style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; = BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px"> <DIV style=3D"FONT: 10pt arial">----- Original Message ----- </DIV> <DIV=20 style=3D"BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: = black"><B>From:</B>=20 <A title=3Dpaulk at UNISERVE.COM href=3D"mailto:paulk at UNISERVE.COM">Paul = Kerslake</A>=20 </DIV> <DIV style=3D"FONT: 10pt arial"><B>To:</B> <A = title=3DEUPHORIA at LISTSERV.MUOHIO.EDU=20 = </A>=20 </DIV> <DIV style=3D"FONT: 10pt arial"><B>Sent:</B> Tuesday, November 07, = 2000 10:29=20 AM</DIV> <DIV style=3D"FONT: 10pt arial"><B>Subject:</B> Find what?</DIV> <DIV><FONT face=3DArial size=3D2></FONT><FONT face=3DArial = size=3D2></FONT><BR></DIV> <DIV><FONT face=3DArial size=3D2>Hi evr'yone</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>I was wondering about find(). What if = there are 2=20 of the same characters in a sequence? Like this:</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>sequence word</FONT></DIV> <DIV><FONT face=3DArial size=3D2>word=3D"beet"</FONT></DIV> <DIV><FONT face=3DArial size=3D2>atom findit</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>findit=3Dfind("e", word)</FONT></DIV> <DIV><FONT face=3DArial size=3D2>? findit</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>Does it give a [2..3] = back?</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>-->Thanks</FONT></DIV> <DIV><FONT face=3DArial size=3D2>--->Thomas</FONT></DIV> <DIV><FONT face=3DArial=20 ------=_NextPart_000_02AB_01C048A7.CD71CEE0--
3. Re: Find what?
- Posted by Derek Parnell <dparnell at BIGPOND.NET.AU> Nov 07, 2000
- 463 views
------=_NextPart_000_02C0_01C048A8.9DD288E0 charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable OOOOPS! That won't work. That's what you get from trying to code while = eating breakfast at the same time. Try this instead... sequence result, word integer x result =3D {} word =3D "experience" for i =3D 1 to length(word) do if word[i] =3D 'e' then result &=3D i end if end for ? result -- Should display {1,4,7,10} ------ Derek Parnell Melbourne, Australia (Vote [1] The Cheshire Cat for Internet Mascot) ----- Original Message -----=20 From: Derek Parnell=20 To: EUPHORIA at LISTSERV.MUOHIO.EDU=20 Sent: Tuesday, November 07, 2000 10:45 AM Subject: Re: Find what? Hi Thomas, no it doesn't return a sequence. From the manual:- find Syntax: i =3D find(x, s) =20 Description: Find x as an element of s. If successful, return = the index of the first element of s that matches. If unsuccessful return = 0. =20 Note the key phrase in the manual "index of the first element". To find all occurrences try this... sequence result, word integer x result =3D {} word =3D "experience" for i =3D 1 to length(word) do x =3D find('e', word) if x then result &=3D x end if end for ? result -- Should display {1,4,7,10} ------ Derek Parnell Melbourne, Australia (Vote [1] The Cheshire Cat for Internet Mascot) ----- Original Message -----=20 From: Paul Kerslake=20 To: EUPHORIA at LISTSERV.MUOHIO.EDU=20 Sent: Tuesday, November 07, 2000 10:29 AM Subject: Find what? Hi evr'yone I was wondering about find(). What if there are 2 of the same = characters in a sequence? Like this: sequence word word=3D"beet" atom findit findit=3Dfind("e", word) ? findit Does it give a [2..3] back? -->Thanks --->Thomas -------/\=3D=3D=3D=3D ------=_NextPart_000_02C0_01C048A8.9DD288E0 charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=3DContent-Type content=3D"text/html; = charset=3Diso-8859-1"> <META content=3D"MSHTML 5.50.4207.2601" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV><FONT face=3DArial size=3D2>OOOOPS! That won't work. That's what = you get from=20 trying to code while eating breakfast at the same time.</FONT></DIV> <DIV><FONT face=3DArial size=3D2>Try this instead...</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV> <P><FONT size=3D2>sequence result, word<BR>integer x<BR></FONT><FONT = size=3D2>result=20 =3D {}<BR>word =3D "experience"</FONT><FONT size=3D2><BR>for i =3D 1 to = length(word)=20 do<BR> if word[i] =3D = 'e' then<BR> =20 result &=3D i<BR> end if<BR>end for<BR>? result -- Should = display=20 {1,4,7,10}</FONT></P></DIV> <DIV>------<BR>Derek Parnell<BR>Melbourne, Australia<BR>(Vote [1] The = Cheshire=20 Cat for Internet Mascot)<BR></DIV> <BLOCKQUOTE dir=3Dltr=20 style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; = BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px"> <DIV style=3D"FONT: 10pt arial">----- Original Message ----- </DIV> <DIV=20 style=3D"BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: = black"><B>From:</B>=20 <A title=3Ddparnell at BIGPOND.NET.AU = href=3D"mailto:dparnell at BIGPOND.NET.AU">Derek=20 Parnell</A> </DIV> <DIV style=3D"FONT: 10pt arial"><B>To:</B> <A = title=3DEUPHORIA at LISTSERV.MUOHIO.EDU=20 = </A>=20 </DIV> <DIV style=3D"FONT: 10pt arial"><B>Sent:</B> Tuesday, November 07, = 2000 10:45=20 AM</DIV> <DIV style=3D"FONT: 10pt arial"><B>Subject:</B> Re: Find what?</DIV> <DIV><FONT face=3DArial size=3D2></FONT><FONT face=3DArial = size=3D2></FONT><BR></DIV> <DIV><FONT face=3DArial size=3D2>Hi Thomas,</FONT></DIV> <DIV><FONT face=3DArial size=3D2>no it doesn't return a = sequence.</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>From the manual:-</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV> <CENTER><B>find</B></CENTER> <P> <TABLE cellSpacing=3D2 cellPadding=3D2 border=3D0> <TBODY> <TR> <TD vAlign=3Dtop><B>Syntax:</B></TD> <TD><FONT face=3D"Arial, Helvetica">i =3D find(x, s) = </FONT></TD></TR> <TR> <TD vAlign=3Dtop><B>Description:</B></TD> <TD>Find x as an element of s. If successful, return the index of = the=20 first element of s that matches. If unsuccessful return 0.=20 </TD></TR></TBODY></TABLE></P> <P><FONT face=3DArial size=3D2></FONT> </P> <P><FONT face=3DArial size=3D2>Note the key phrase in the manual = "index of the=20 <STRONG>first</STRONG> element".</FONT></P> <P><FONT face=3DArial size=3D2>To find all occurrences try = this...</FONT></P> <P><FONT size=3D2>sequence result, word<BR>integer x<BR></FONT><FONT=20 size=3D2>result =3D {}<BR>word =3D "experience"</FONT><FONT = size=3D2><BR>for i =3D 1 to=20 length(word) do<BR> x =3D find('e', word)<BR> if x=20 then<BR> result &=3D x<BR> end = if<BR>end=20 for<BR>? result -- Should display {1,4,7,10}</FONT></P></DIV> <DIV>------<BR>Derek Parnell<BR>Melbourne, Australia<BR>(Vote [1] The = Cheshire=20 Cat for Internet Mascot)<BR></DIV> <BLOCKQUOTE dir=3Dltr=20 style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; = BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px"> <DIV style=3D"FONT: 10pt arial">----- Original Message ----- </DIV> <DIV=20 style=3D"BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: = black"><B>From:</B>=20 <A title=3Dpaulk at UNISERVE.COM = href=3D"mailto:paulk at UNISERVE.COM">Paul=20 Kerslake</A> </DIV> <DIV style=3D"FONT: 10pt arial"><B>To:</B> <A=20 title=3DEUPHORIA at LISTSERV.MUOHIO.EDU=20 = </A>=20 </DIV> <DIV style=3D"FONT: 10pt arial"><B>Sent:</B> Tuesday, November 07, = 2000 10:29=20 AM</DIV> <DIV style=3D"FONT: 10pt arial"><B>Subject:</B> Find what?</DIV> <DIV><FONT face=3DArial size=3D2></FONT><FONT face=3DArial=20 size=3D2></FONT><BR></DIV> <DIV><FONT face=3DArial size=3D2>Hi evr'yone</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>I was wondering about find(). What = if there are=20 2 of the same characters in a sequence? Like this:</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>sequence word</FONT></DIV> <DIV><FONT face=3DArial size=3D2>word=3D"beet"</FONT></DIV> <DIV><FONT face=3DArial size=3D2>atom findit</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>findit=3Dfind("e", = word)</FONT></DIV> <DIV><FONT face=3DArial size=3D2>? findit</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>Does it give a [2..3] = back?</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>-->Thanks</FONT></DIV> <DIV><FONT face=3DArial size=3D2>--->Thomas</FONT></DIV> <DIV><FONT face=3DArial=20 DY></HTML> ------=_NextPart_000_02C0_01C048A8.9DD288E0--
4. Re: Find what?
- Posted by Asif Baloch <cyberego at QTA.PAKNET.COM.PK> Nov 07, 2000
- 454 views
>Instead of using ? findit, you can use print or printf. Its much >better.Use %s to represnt text values or simply speaking,... strings ;) Hope this helps........ Asif Baloch MBA (Information Technology) BBA (CBIS)
5. Re: Find what?
- Posted by Brian Broker <bkb at CNW.COM> Nov 07, 2000
- 470 views
On Mon, 6 Nov 2000 15:29:08 -0800, Thomas wrote: >Hi evr'yone > >I was wondering about find(). What if there are 2 of the same characters in a sequence? Like this: > >sequence word >word="beet" >atom findit > >findit=find("e", word) >? findit > >Does it give a [2..3] back? > >-->Thanks >--->Thomas >-------/\==== Well this sounds like a job for 'experimentation'!!! But since I suspect you might already know the answer, I'll give you something more to chew on. Suppose your real question was something like: "How might I get the indices of all elements found in a sequence?" or "how about all sequences matched?" Here's some recursive functions I posted to the list a little while back. Recursive functions are functions that call themselves to get the answer you're looking for: ... These return empty sequences if there's no match but I really don't see the advantage of returning zero since you'd have to store the result in an object and test for type that way... -- find_all/match_all recursive functions -- Brian Broker ----------------------------- function find_all( object x, sequence s ) -- returns: sequence containing indices of all occurences -- if unsuccessful return empty sequence {} object found found = find( x, s ) if found then found &= found + find_all( x, s[found+1..length(s)] ) else return {} end if return found end function ----------------------------- function match_all( sequence s1, sequence s2 ) -- returns: sequence containing indices of all matches -- if unsuccessful return empty sequence {} object found found = match( s1, s2 ) if found then found &= found + match_all( s1, s2[found+1..length(s2)] ) else return {} end if return found end function ----------------------------- -- test the functions constant blah = {10,20,3,1,3,4,11,15} constant names = {"mary","john","mary","frank",""} constant zippy = {{12,13,14,15},{11,12,13,14,15},{10,11,12,13,14}} constant string1 = "My name is Brian. My name is not Thomas. What is your name?", string2 = "Euphoria is fun. Euphoria is also flexible and fast." ? find_all(3,blah) ---output is {3,5} ? find_all(11,blah) ---output is {7} ? find_all(28,blah) ---output is {} ? find_all("mary",names) ---output is {1,3} ? find_all("john",names) ---output is {2} ? find_all("joebob",names) ---output is {} ---these are tricky ;) ? find(12,zippy) ---output is 0 ? find_all(12,zippy) ---output is {} ? match( "name", string1 ) --output is 4 ? match_all( "name", string1 ) --output is {4,23,57} ? match( "not", string1 ) --output is 31 ? match_all( "not", string1 ) --output is {31} ? match( "Euphoria", string2 ) --output is 1 ? match_all( "Euphoria", string2 ) --output is {1,19} ? match( "Python", string2 ) --output is 0 ? match_all( "Python", string2 ) --output is {} -- have fun, -- Brian
6. Re: Find what?
- Posted by Liona Kerslake <paulk at UNISERVE.COM> Nov 06, 2000
- 475 views
- Last edited Nov 07, 2000
------=_NextPart_000_0006_01C04838.0037CFC0 charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable ----- Original Message -----=20 From: Derek Parnell=20 To: EUPHORIA at LISTSERV.MUOHIO.EDU=20 Sent: Monday, November 06, 2000 3:51 PM Subject: Re: Find what? OOOOPS! That won't work. That's what you get from trying to code while = eating breakfast at the same time. Try this instead... =20 sequence result, word integer x result =3D {} word =3D "experience" for i =3D 1 to length(word) do if word[i] =3D 'e' then result &=3D i end if end for ? result -- Should display {1,4,7,10} ------ Derek Parnell Melbourne, Australia (Vote [1] The Cheshire Cat for Internet Mascot) ----- Original Message -----=20 From: Derek Parnell=20 To: EUPHORIA at LISTSERV.MUOHIO.EDU=20 Sent: Tuesday, November 07, 2000 10:45 AM Subject: Re: Find what? Hi Thomas, no it doesn't return a sequence. =20 From the manual:- =20 find Syntax: i =3D find(x, s) =20 Description: Find x as an element of s. If successful, return = the index of the first element of s that matches. If unsuccessful return = 0. =20 =20 Note the key phrase in the manual "index of the first element". To find all occurrences try this... sequence result, word integer x result =3D {} word =3D "experience" for i =3D 1 to length(word) do x =3D find('e', word) if x then result &=3D x end if end for ? result -- Should display {1,4,7,10} ------ Derek Parnell Melbourne, Australia (Vote [1] The Cheshire Cat for Internet Mascot) ----- Original Message -----=20 From: Paul Kerslake=20 To: EUPHORIA at LISTSERV.MUOHIO.EDU=20 Sent: Tuesday, November 07, 2000 10:29 AM Subject: Find what? Hi evr'yone =20 I was wondering about find(). What if there are 2 of the same = characters in a sequence? Like this: =20 sequence word word=3D"beet" atom findit =20 findit=3Dfind("e", word) ? findit =20 Does it give a [2..3] back? =20 -->Thanks --->Thomas -------/\=3D=3D=3D=3D Sorry, I meant to add another "bit" to it. I forgot to include = that the users input was used in find(). So it would be something like: include get.e integer input sequence word word=3D"beef" atom findit input=3Dgets(0) findit=3Dfind(input[1], word) --input[1] otherwise the [#,10] = extra 10 for enter is added ? findit =20 --->Thanks ------> Thomas -------/\=3D=3D=3D=3D=3D ------=_NextPart_000_0006_01C04838.0037CFC0 charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META content=3D"text/html; charset=3Diso-8859-1" = http-equiv=3DContent-Type> <META content=3D"MSHTML 5.00.2614.3500" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV> </DIV> <BLOCKQUOTE dir=3Dltr=20 style=3D"BORDER-LEFT: #000000 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: = 0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px"> <DIV style=3D"FONT: 10pt arial">----- Original Message ----- </DIV> <DIV=20 style=3D"BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: = black"><B>From:</B>=20 <A href=3D"mailto:dparnell at BIGPOND.NET.AU" = title=3Ddparnell at BIGPOND.NET.AU>Derek=20 Parnell</A> </DIV> <DIV style=3D"FONT: 10pt arial"><B>To:</B> <A=20 href=3D"mailto:EUPHORIA at LISTSERV.MUOHIO.EDU"=20 title=3DEUPHORIA at LISTSERV.MUOHIO.EDU>EUPHORIA at LISTSERV.MUOHIO.EDU</A> = </DIV> <DIV style=3D"FONT: 10pt arial"><B>Sent:</B> Monday, November 06, 2000 = 3:51=20 PM</DIV> <DIV style=3D"FONT: 10pt arial"><B>Subject:</B> Re: Find what?</DIV> <DIV><BR></DIV> <DIV><FONT face=3DArial size=3D2>OOOOPS! That won't work. That's what = you get from=20 trying to code while eating breakfast at the same time.</FONT></DIV> <DIV><FONT face=3DArial size=3D2>Try this instead...</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV> <P><FONT size=3D2>sequence result, word<BR>integer x<BR></FONT><FONT=20 size=3D2>result =3D {}<BR>word =3D "experience"</FONT><FONT = size=3D2><BR>for i =3D 1 to=20 length(word) do<BR> if word[i] =3D=20 'e' then<BR> result = &=3D i<BR> end=20 if<BR>end for<BR>? result -- Should display = {1,4,7,10}</FONT></P></DIV> <DIV>------<BR>Derek Parnell<BR>Melbourne, Australia<BR>(Vote [1] The = Cheshire=20 Cat for Internet Mascot)<BR></DIV> <BLOCKQUOTE dir=3Dltr=20 style=3D"BORDER-LEFT: #000000 2px solid; MARGIN-LEFT: 5px; = MARGIN-RIGHT: 0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px"> <DIV style=3D"FONT: 10pt arial">----- Original Message ----- </DIV> <DIV=20 style=3D"BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: = black"><B>From:</B>=20 <A href=3D"mailto:dparnell at BIGPOND.NET.AU" = title=3Ddparnell at BIGPOND.NET.AU>Derek=20 Parnell</A> </DIV> <DIV style=3D"FONT: 10pt arial"><B>To:</B> <A=20 href=3D"mailto:EUPHORIA at LISTSERV.MUOHIO.EDU"=20 = title=3DEUPHORIA at LISTSERV.MUOHIO.EDU>EUPHORIA at LISTSERV.MUOHIO.EDU</A> = </DIV> <DIV style=3D"FONT: 10pt arial"><B>Sent:</B> Tuesday, November 07, = 2000 10:45=20 AM</DIV> <DIV style=3D"FONT: 10pt arial"><B>Subject:</B> Re: Find what?</DIV> <DIV><FONT face=3DArial size=3D2></FONT><FONT face=3DArial=20 size=3D2></FONT><BR></DIV> <DIV><FONT face=3DArial size=3D2>Hi Thomas,</FONT></DIV> <DIV><FONT face=3DArial size=3D2>no it doesn't return a = sequence.</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>From the manual:-</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV> <CENTER><B>find</B></CENTER> <P> <TABLE border=3D0 cellPadding=3D2 cellSpacing=3D2> <TBODY> <TR> <TD vAlign=3Dtop><B>Syntax:</B></TD> <TD><FONT face=3D"Arial, Helvetica">i =3D find(x, s) = </FONT></TD></TR> <TR> <TD vAlign=3Dtop><B>Description:</B></TD> <TD>Find x as an element of s. If successful, return the index = of the=20 first element of s that matches. If unsuccessful return 0.=20 </TD></TR></TBODY></TABLE></P> <P><FONT face=3DArial size=3D2></FONT> </P> <P><FONT face=3DArial size=3D2>Note the key phrase in the manual = "index of the=20 <STRONG>first</STRONG> element".</FONT></P> <P><FONT face=3DArial size=3D2>To find all occurrences try = this...</FONT></P> <P><FONT size=3D2>sequence result, word<BR>integer x<BR></FONT><FONT = size=3D2>result =3D {}<BR>word =3D "experience"</FONT><FONT = size=3D2><BR>for i =3D 1=20 to length(word) do<BR> x =3D find('e', word)<BR> if x=20 then<BR> result &=3D x<BR> end = if<BR>end=20 for<BR>? result -- Should display {1,4,7,10}</FONT></P></DIV> <DIV>------<BR>Derek Parnell<BR>Melbourne, Australia<BR>(Vote [1] = The=20 Cheshire Cat for Internet Mascot)<BR></DIV> <BLOCKQUOTE dir=3Dltr=20 style=3D"BORDER-LEFT: #000000 2px solid; MARGIN-LEFT: 5px; = MARGIN-RIGHT: 0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px"> <DIV style=3D"FONT: 10pt arial">----- Original Message ----- = </DIV> <DIV=20 style=3D"BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: = black"><B>From:</B>=20 <A href=3D"mailto:paulk at UNISERVE.COM" = title=3Dpaulk at UNISERVE.COM>Paul=20 Kerslake</A> </DIV> <DIV style=3D"FONT: 10pt arial"><B>To:</B> <A=20 href=3D"mailto:EUPHORIA at LISTSERV.MUOHIO.EDU"=20 = title=3DEUPHORIA at LISTSERV.MUOHIO.EDU>EUPHORIA at LISTSERV.MUOHIO.EDU</A> = </DIV> <DIV style=3D"FONT: 10pt arial"><B>Sent:</B> Tuesday, November 07, = 2000=20 10:29 AM</DIV> <DIV style=3D"FONT: 10pt arial"><B>Subject:</B> Find what?</DIV> <DIV><FONT face=3DArial size=3D2></FONT><FONT face=3DArial=20 size=3D2></FONT><BR></DIV> <DIV><FONT face=3DArial size=3D2>Hi evr'yone</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>I was wondering about find(). = What if there=20 are 2 of the same characters in a sequence? Like = this:</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>sequence word</FONT></DIV> <DIV><FONT face=3DArial size=3D2>word=3D"beet"</FONT></DIV> <DIV><FONT face=3DArial size=3D2>atom findit</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>findit=3Dfind("e", = word)</FONT></DIV> <DIV><FONT face=3DArial size=3D2>? findit</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>Does it give a [2..3] = back?</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>-->Thanks</FONT></DIV> <DIV><FONT face=3DArial size=3D2>--->Thomas</FONT></DIV> <DIV><FONT face=3DArial = size=3D2>-------/\=3D=3D=3D=3D</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>Sorry, I meant to add another = "bit" to it. I=20 forgot to include that the users input was used in find(). So it = would be=20 something like:</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>include get.e</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>integer input</FONT></DIV> <DIV><FONT face=3DArial size=3D2> <DIV><FONT face=3DArial size=3D2>sequence word</FONT></DIV> <DIV><FONT face=3DArial size=3D2>word=3D"beef"</FONT></DIV> <DIV><FONT face=3DArial size=3D2>atom findit</FONT></DIV> <DIV><FONT face=3DArial = size=3D2></FONT> input=3Dgets(0)</DIV> <DIV><FONT face=3DArial size=3D2>findit=3Dfind(input[1], = word) =20 --input[1] otherwise the [#,10] extra 10 for enter is = added</FONT></DIV> <DIV><FONT face=3DArial size=3D2>? findit</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV> </DIV> <DIV>--->Thanks</DIV> <DIV>------> Thomas</DIV> <DIV> </DIV> = ------=_NextPart_000_0006_01C04838.0037CFC0--
7. Re: Find what?
- Posted by Brian Broker <bkb at CNW.COM> Nov 07, 2000
- 468 views
- Last edited Nov 08, 2000
On Mon, 6 Nov 2000 21:24:52 -0800, Thomas wrote: > Sorry, I meant to add another "bit" to it. I forgot to include that >the users input was used in find(). So it would be something like: > > include get.e > > integer input > sequence word > word="beef" > atom findit > input=gets(0) > findit=find(input[1], word) --input[1] otherwise the [#,10] extra > --10 for enter is added > ? findit > > > --->Thanks > ------> Thomas So what is your question? If I input "beer", I will get: find( 'b', "beef" ) = 1 If I input "elephant", I will get: find( 'e', "beef" ) = 2 If I input "pork", I will get: find( 'p', "beef" ) = 0 If I input "Beef", I will get: find( 'B', "beef" ) = 0 Is this what you want? If not, provide examples like those above and the result you would like to see. Then we'll see about writing a function that produces the desired results. Are you looking for a function like "find_all" or "match_all" that I posted previously? -- Brian
8. Re: Find what?
- Posted by Liona Kerslake <paulk at UNISERVE.COM> Nov 08, 2000
- 444 views
----- Original Message ----- From: Brian Broker <bkb at CNW.COM> To: <EUPHORIA at LISTSERV.MUOHIO.EDU> Sent: Tuesday, November 07, 2000 4:41 PM Subject: Re: Find what? > On Mon, 6 Nov 2000 21:24:52 -0800, Thomas wrote: > > > Sorry, I meant to add another "bit" to it. I forgot to include that > >the users input was used in find(). So it would be something like: > > > > include get.e > > > > integer input > > sequence word > > word="beef" > > atom findit > > input=gets(0) > > findit=find(input[1], word) --input[1] otherwise the [#,10] extra > > --10 for enter is added > > ? findit > > > > > > --->Thanks > > ------> Thomas > > So what is your question? > > If I input "beer", I will get: > find( 'b', "beef" ) = 1 > > If I input "elephant", I will get: > find( 'e', "beef" ) = 2 > > If I input "pork", I will get: > find( 'p', "beef" ) = 0 > > If I input "Beef", I will get: > find( 'B', "beef" ) = 0 > > Is this what you want? If not, provide examples like those above and the > result you would like to see. Then we'll see about writing a function that > produces the desired results. Are you looking for a function > like "find_all" or "match_all" that I posted previously? > > -- Brian Um............how about we forget what I wrote. Sorry I've got a lot of stuff buzzing aroudn right now so I've gotten sidetracked. What I mean is, if the user enters "e" and Euphoria find()'s "e" in "beet", there are 2. What happens then? Does Euphoria give you the placement of the first "e". Sorry for the confusion... Thomas
9. Re: Find what?
- Posted by "Cuny, David at DSS" <David.Cuny at DSS.CA.GOV> Nov 08, 2000
- 475 views
Thomas/Liona Kerslake/paulk wrote: > Euphoria find()'s "e" in "beet", there are 2. > What happens then? Does Euphoria give you the > placement of the first "e"? Yes. You can do something like this untested code to gather a list of all indexes: function gather( object o, sequence s ) sequence list list = {} for i = 1 to length( s ) do if equal( o, s[i] ) then list &= i end if end for return list end function -- David Cuny