diff --git a/lab4/report/report.tex b/lab4/report/report.tex index 294d24b..24cb868 100644 --- a/lab4/report/report.tex +++ b/lab4/report/report.tex @@ -256,6 +256,27 @@ propFilterByPredicateAlwaysTrue xs = filterByPredicate (\_ -> True) xs == xs \end{lstlisting} +В листинге~\ref{lst:broken1} представлена реализация функции \texttt{filterByPredicate}, которая не пройдёт ни один из перечисленных тестов. А в листинге~\ref{lst:broken2} представлена реализация, которая не пройдёт два из трёх тестов, первый и третий. + +\begin{lstlisting}[caption={Пример реализации функции filterByPredicate, которая не пройдёт ни один тест.}, label={lst:broken1}] +filterByPredicate :: (a -> Bool) -> [a] -> [a] +filterByPredicate _ [] = [] +filterByPredicate predicate (x:xs) + | not $ predicate x = x : x : filteredTail + | otherwise = x : x : filteredTail + where + filteredTail = filterByPredicate predicate xs +\end{lstlisting} + +\begin{lstlisting}[caption={Пример реализации функции filterByPredicate, которая не пройдёт первый и третий тесты.}, label={lst:broken2}] +filterByPredicate :: (a -> Bool) -> [a] -> [a] +filterByPredicate _ [] = [] +filterByPredicate predicate (x:xs) + | not $ predicate x = x : filteredTail + | otherwise = filteredTail + where + filteredTail = filterByPredicate predicate xs +\end{lstlisting} \subsection{Запуск тестов}