From a5b624a33305b38042ba1498730937d3e64ad78a Mon Sep 17 00:00:00 2001 From: Arity-T Date: Fri, 6 Dec 2024 18:59:49 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=B2=20=D0=BE=D1=82=D1=87=D1=91=D1=82=20=D0=BF=D1=80=D0=B8?= =?UTF-8?q?=D0=BC=D0=B5=D1=80=D1=8B=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8?= =?UTF-8?q?=D0=B9=20=D0=BD=D0=B5=D0=BF=D1=80=D0=BE=D1=85=D0=BE=D0=B4=D1=8F?= =?UTF-8?q?=D1=89=D0=B8=D1=85=20=D1=82=D0=B5=D1=81=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lab4/report/report.tex | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) 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{Запуск тестов}