There are several different ways to approach this; while the temptation is to go straight to recursion on this, it's nice to avoid using recursion explicitly if there is another option.
. , Haskell, , , . (), :
after :: Int -> Int -> [Int] -> Bool
after a b = elem b . dropWhile (/= a)
, ; , a, , , , b . a, [] , , b, False, .
, , "a" "b" , , . : tail -;)
, :
;
. ,
, ( ).
data State =
FindA | FindB | Found
deriving Eq
"" (aka ) .
after :: Int -> Int -> [Int] -> Bool
after a b xs = foldl go FindA xs == Found
where
go FindA x = if x == a then FindB else FindA
go FindB x = if x == b then Found else FindB
go Found _ = Found
, :
after :: Int -> Int -> [Int] -> Bool
after _ _ [] = False
after a b (x:xs)
| x == a = b `elem` xs
| otherwise = after a b xs
!