Я пытаюсь найти способ просмотреть мой список кортежей и сравнить первый элемент каждого кортежа с заданной строкой.
Это была моя попытка реализовать "find":
-- (iterable) should be what the find function uses to "iterate" the list,
-- but i'm sure i'm going about this the wrong way.
findNextState :: DFA -> Char -> State -> State
findNextState dfa input state
| find matchTransition state input fst' (iterable) == True transitions = thd' (iterable)
| otherwise = ""
Вот что у меня сейчас, и это работает только для первого кортежа в списке.
fst' (a,_,_) = a
snd' (_,a,_) = a
thd' (_,_,a) = a
findNextState :: DFA -> Char -> State -> State
findNextState dfa input state
| matchTransition state input (head transitions) = thd' (head (frt'' dfa))
| otherwise = ""
matchTransition :: State -> Char -> Transition -> Bool
matchTransition from input funct
| from == fst' funct && -- case for function that takes a 0 or 1
if elem input ['0','1'] then snd' funct == 'd' else False = True
| from == fst' funct && -- case for function that takes a .
if input == '.' then snd' funct == '.' else False = True
| otherwise = False