string - Position of a sublist in a list haskell -
OK, I am trying to write a function that determines the position of a string if the first one Say the suburbs of "Pie" is like a string and someone else like "Apple" will return to function 5, because the first letter of "pie" is in string "apple" on position 5
Can anybody do this?
See the question it was told a few days ago (and answered) and your problem
My solution:
findStr :: string - & gt; String - & gt; Maybe int findStr pat str = findStrHelp pat str 0 where findStrHelp _ [] _ = nothing FindStrHelp pat s @ (x: xs) n | Pat == (le (length pat) s) = bus n | Otherwise = Search SRTLP Pat XS (N + 1)
To get this code without possibly getting, just remove the findStrHelp _ [] _
and With just n
, n
can also be with
typing sign
int
.
Comments
Post a Comment