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. The problem im not sure how to compare the lists for equality. Here the is what i have so far..... substitute :: Eq a => [a] -> [a] -> [a] -> [a] substitute _ [] _ = [] substitute ys (x:xs) zs | ys == x = zs:xs | otherwise = x:substitute ys xs zs Any help would be greatly appreciated. Thanks Stephanie
"Stephanie Randles" <srandles@bigpond.net.au> writes:
I'm 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.
Lest I be accused of solving people's homework (alas, I have none of my own!),...
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.
...I shall merely point out that (==) is defined for lists, and suggest the use of isPrefixOf -kzm -- If I haven't seen further, it is by standing in the footprints of giants
participants (2)
-
Ketil Malde -
Stephanie Randles