Question: Write the following functions in Haskell isSubsequence:: (Eq a) => [a] rightarrow [a] rightarrow Bool. Is the first argument a subsequence of the second one?
Write the following functions in Haskell
![Write the following functions in Haskell isSubsequence:: (Eq a) => [a] rightarrow](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f3d7db5ad2d_53866f3d7dae963e.jpg)
isSubsequence:: (Eq a) => [a] rightarrow [a] rightarrow Bool. Is the first argument a subsequence of the second one? *Code> isSubsequence [3, 4] [1, 2, 3, 4, 5] True *Code> isSubsequence [2, 4] [1, 2, 3, 4, 5] False *Code> isSubsequence [] [1, 2, 3, 4, 5] True *Code> isSubsequence [4, 3, 2] [1, 2, 3, 4, 5] False *Code> indexof:: (Eq a) => [a] rightarrow [a] rightarrow Maybe Int. Find the index where the first argument begins as a subsequence of the second argument, if there is such an index. Return Just the index when found, or Nothing when the index doesn't exist. Indexing begins at zero. *Code> indexof [2, 3] [1, 2, 3, 4, 5] Just 1 *Code> indexof [3, 4, 5] [1, 2, 3, 4, 5] Just 2 *Code> indexof [2, 4] [1, 2, 3, 4, 5] Nothing
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
