Advertisement
Guest User

Untitled

a guest
Feb 16th, 2020
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. lcs :: (Eq a) => [a] -> [a] -> [a]
  2. lcs [] _ = []
  3. lcs _ [] = []
  4.  
  5. lcs (x:xs) (y:ys) =
  6.     if (x == y) then x : lcs xs ys
  7.     else longer (lcs xs (y:ys), lcs (x:xs) ys)
  8.     where longer (a, b) = if (length a > length b) then a else b
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement