Re: Find what?

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

------=_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>&nbsp;</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>&nbsp;</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>&nbsp;&nbsp;if&nbsp;word[i] =3D=20
  'e'&nbsp;then<BR>&nbsp;&nbsp;&nbsp;&nbsp; result =
&amp;=3D&nbsp;i<BR>&nbsp; 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>&nbsp;</DIV>
    <DIV><FONT face=3DArial size=3D2>From the manual:-</FONT></DIV>
    <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</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>&nbsp;</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>&nbsp; x =3D find('e', word)<BR>&nbsp; if x=20
    then<BR>&nbsp;&nbsp;&nbsp;&nbsp; result &amp;=3D x<BR>&nbsp; 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>&nbsp;</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>&nbsp;</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>&nbsp;</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>&nbsp;</DIV>
      <DIV><FONT face=3DArial size=3D2>Does it give a [2..3] =
back?</FONT></DIV>
      <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
      <DIV><FONT face=3DArial size=3D2>--&gt;Thanks</FONT></DIV>
      <DIV><FONT face=3DArial size=3D2>---&gt;Thomas</FONT></DIV>
      <DIV><FONT face=3DArial =
size=3D2>-------/\=3D=3D=3D=3D</FONT></DIV>
      <DIV>&nbsp;</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>&nbsp;</DIV>
      <DIV><FONT face=3DArial size=3D2>include get.e</FONT></DIV>
      <DIV>&nbsp;</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>&nbsp;input=3Dgets(0)</DIV>
      <DIV><FONT face=3DArial size=3D2>findit=3Dfind(input[1], =
word)&nbsp;&nbsp;&nbsp;=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>&nbsp;</DIV>
      <DIV>&nbsp;</DIV>
      <DIV>---&gt;Thanks</DIV>
      <DIV>------&gt; Thomas</DIV>
      <DIV>&nbsp;</DIV>
      =

------=_NextPart_000_0006_01C04838.0037CFC0--

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

Search



Quick Links

User menu

Not signed in.

Misc Menu