Re: Find what?
------=_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--
|
Not Categorized, Please Help
|
|