# subsequencing!

Stephanie Randles Stephanie Randles" <srandles@bigpond.net.au
Wed, 7 Nov 2001 15:19:37 +1100

```This is a multi-part message in MIME format.

------=_NextPart_000_0036_01C1679F.9CDA55A0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi,
Im studying for an exam in Haskell program and for practice we have =
been given exercises to complete on our own. The answers have not been =
put up on the website either.

So i was hoping for some help with this little program here. The idea is =
to be able to substitute the first occurrence of a given subsequence in =
a list with another subsequence.=20

The problem im not sure how to compare the lists for equality. Here the =
is what i have so far.....

substitute :: Eq a =3D> [a] -> [a] -> [a] -> [a]
substitute _ [] _ =3D []
substitute ys (x:xs) zs
| ys =3D=3D x =3D zs:xs
| otherwise =3D x:substitute ys xs zs

Any help would be greatly appreciated.=20

Thanks Stephanie

------=_NextPart_000_0036_01C1679F.9CDA55A0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 5.50.4522.1800" name=3DGENERATOR>
<STYLE></STYLE>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;Im studying for an =
exam in=20
Haskell program and for practice we have been given exercises to =
complete on our=20
own. The answers have not been put up on the website =
either.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>So i was hoping for some help with this =
little=20
program here. The idea is to be able to substitute the first occurrence =
of a=20
given subsequence in a list with another subsequence. </FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>The problem im not sure how to compare =
the lists=20
for equality. Here the is what i have so far.....</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>substitute :: Eq a =3D&gt; [a] -&gt; =
[a] -&gt; [a]=20
-&gt; [a]<BR>substitute _ [] _ =3D []<BR>substitute ys (x:xs)=20
zs<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | ys =3D=3D x =3D=20
zs:xs<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | otherwise =3D =
x:substitute=20
ys xs zs</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Any help would be greatly appreciated.=20
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks =
Stephanie</FONT></DIV></BODY></HTML>

------=_NextPart_000_0036_01C1679F.9CDA55A0--

```