indexOf:: (Eqa) =>a-> [a] ->Int
indexOf x ys =case elemIndex x ys ofJust a -> a
Nothing->-1splitBy:: (Eqa) =>a-> [a] -> ([a], [a])
splitBy x =span (/= x)
joinWithout:: (Eqa) =>a-> [a] -> [a]
joinWithout x ys =let (a, b) = splitBy x ys in (a ++tail b)
isSubseqOf:: (Eqa) => [a] -> [a] ->Bool
isSubseqOf [] _ =True
isSubseqOf _ []=False-- @TODO: strip each element of the referenced list after each recursion
isSubseqOf (x : xs) ys
|null ys'' =False|otherwise=case xs of
(z : _) ->let idX = indexOf x ys
idZ = indexOf z ys incase (compare idX idZ) ofLT-> isSubseqOf xs (joinWithout x ys)
_ ->False
_ -> isSubseqOf xs (joinWithout x ys)
where (ys', ys'') = splitBy x ys