-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
labs Aleksei Pakhomov #5
base: master
Are you sure you want to change the base?
Conversation
Сделайте свой репозиторий приватным, пожалуйста. |
intersect [] _ = [] | ||
intersect (x:xs) (y:ys) | ||
| x == y = [x] ++ intersect xs ys | ||
| otherwise = intersect xs ys |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Я не вижу, как у вас проходит тест
intersect [1, 2, 3] [3, 4, 5] `shouldBe` [3]
У меня там получается пустой список с такой реализацией. Первый пример в задании тоже не должен работать.
Кроме ошибки в intersect, всё остальное отлично. Ставлю 18, её можно исправить и получить 20. |
Можете лабораторные 2 и 3 вынести в отдельные PR? |
coprime :: Integer -> Integer -> Bool | ||
coprime a b | ||
| c == 0 || d == 0 = False | ||
| c == 1 || d == 1 = True | ||
| c > d = coprime (c - d) d | ||
| otherwise = coprime (d - c) c | ||
where c = abs a | ||
d = abs b | ||
|
||
max3, median3 :: Integer -> Integer -> Integer -> Integer | ||
max3 x y z = if max x y >= z then max x y else z | ||
median3 x y z = if max x y >= z then (if x >= y then max y z else max x z) else max x y | ||
|
||
newtype Poly a = Poly [a] | ||
xPows x = map (\n -> x**n) [0..] | ||
getCoefs (Poly p) = p | ||
discardZeroes [] = [] | ||
discardZeroes p = if (last p /= 0) then p | ||
else discardZeroes $ init p | ||
makePoly p x = sum $ zipWith (*) (getCoefs p) (xPows x) | ||
applyPoly p x = makePoly p x |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Сами функции добавили, а тесты для них нет.
Уже не надо, я посмотрел изменения с последней проверки. |
No description provided.